Page 1 of 1

Running php from crontab

Posted: Thu Dec 03, 2009 4:12 am
by Nunners
I'm being really thick... I've got various crons setup that run php scripts, and unfortunately my server went belly up recently so had to start from scratch. Got all the php files, and crontab list, but having problems running php from the crontab.

I know I had to put link in a "safe directory" to run php from, but can't remember how I did it... can anyone give me a hint, and this time I'll write down what I did!

Thanks
Nunners

Re: Running php from crontab

Posted: Thu Dec 03, 2009 4:47 pm
by AbraCadaver
Depends. Is it /etc/crontab or a specific user's crontab?

As long as the php files are readable by the user who owns the crontab, then everything should be fine if you run them like: /usr/bin/php /path/to/file.php

If you run them like: /path/to/file.php because you have a #!/usr/bin/php at the top of the files, then the PHP file needs to be readable and executable by the user.

-Shawn

Re: Running php from crontab

Posted: Sat Dec 05, 2009 12:41 pm
by kaisellgren
Make sure the file is indeed executable by the user. Once I wondered for a while why my crons failed. :) Also, it's likely a good idea to place the file below the doc root.