Help - Search - Members - Calendar
Full Version: crontab to run php script
The Planet Forums > Control Panels > Plesk
guischarf
Hello,

I wrote I a small php script that reads an xml file from a different host and writes it to a directory on my host. The script works ok if I run it via browser or command line (php -f /home/httpd/vhosts/somedir/httpdocs/sms/the_script.php). However, does not seem to run when I set a crontab.

The crontab job looks like this when listed with
CODE
crontab -u me -l


CODE
MAILTO=me@somemail.net

       5       *       *       *       *       /usr/bin/php -f /home/httpd/vhosts/somedir/httpdocs/sms/the_script.php


Any ideas what could be wrong?

I set permision 755 on the_script.php and 644 to the file the_script.php writes to. The containing directory to 755
Squire
You might just want to use wget if you can. For example what I use right in the domain contrab is something along the lnies of

CODE
5 * * * * wget -q [url="http://www.yourdomain.com/scriptname.php"]http://www.yourdomain.com/scriptname.php[/url] -O /dev/null
guischarf
Thanks Squire for your answer. I am no completely sure what this is doing. Would wget call the script as if it were an browswer causing it to execute? The -O /dev/null directive sends any output to /dev/null? What if my script has no output, I still need -O?

Thanks so much.

QUOTE (Squire)
You might just want to use wget if you can.  For example what I use right in the domain contrab is something along the lnies of

CODE
5 * * * * wget -q [url="http://www.yourdomain.com/scriptname.php"]http://www.yourdomain.com/scriptname.php[/url] -O /dev/null
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.