Cron question

John Almberg jalmberg at
Thu Apr 24 20:26:30 UTC 2008

I have recently switched from Linux to FreeBSD for my web server.  
Absolutely love it, but am having one difficulty that is driving me  

I wouldn't think that cron would run differently on BSD than Linux,  
but it seemingly does. I have a user crontab that runs a PHP script  
once a day. This worked effortlessly on the old box.

If I am logged in as the user (gs), I can run the script without  
problem just by typing the command line ./script.php, or /full/path/ 

The trouble comes when I try to run this script with cron. I have  
something like this in the gs user crontab:

0 15 * * * /home/gs/bin/script.php >>/home/gs/log/script.log

I can see from the cron log that cron runs script.php at the  
appointed hour:

	Apr 24 15:00:03 on /usr/sbin/cron[72414]: (gs) CMD (/home/gs/bin/ 
script.php >>/home/gs/log/script.log)

HOWEVER, absolutely nothing happens as a result. No error message in  
any /var/log file, and script.log is not even touched, even though  
the script is quite verbose and logs a bunch of stuff when it runs.

It is as if the script was never run. I have looked at this every  
which way, but it doesn't make any sense to me. There are other  
scripts in the same crontab that run without problem.

I have tried changing the crontab to:

0 15 * * * /usr/local/bin/php /home/gs/bin/script.php >>/home/gs/log/ 

But that has no effect.

So, the question is, how can a script that runs perfectly when  
executed by user gs from the command line, not work at all when run  
as user gs's crontab? Not even generate an error message or log  
entry? What is different in the user crontab runtime environment?

Any insight much appreciated.

Brgds: John

[gs at on ~]$ uname -a
Dec  3 09:46:53 EST 2007     root at 
INET_ON  amd64

[gs at on ~]$ which php

More information about the freebsd-questions mailing list