Portal Home > Knowledgebase > Articles Database > crontab to run PHP [without using wget and lynx]

crontab to run PHP [without using wget and lynx]

Posted by kamcm, 08-07-2007, 02:54 PM
Hello, I don't know how to use crontab to run PHP without using wget and lynx 1) The PHP script can run via SSH command line mode without problem 2) I can use crontab to run the PHP script with wget or lynx. However, 3) The script will not run if i using below entry 1 2 * * * php /path/to/script/crontest.php 1 2 * * * php -q /path/to/script/crontest.php 1 2 * * * php -f /path/to/script/crontest.php 1 2 * * * /usr/local/bin/php - /path/to/script/crontest.php 1 2 * * * /usr/local/bin/php -f /path/to/script/crontest.php 1 2 * * * /usr/local/bin/php -q /path/to/script/crontest.php Please give me some suggestion. Thanks Kam

Posted by SmartTux, 08-07-2007, 02:56 PM
what is the output of "php -q /path/to/script/crontest.php" when directly run through shell ? Are those in root's crontab ?

Posted by kamcm, 08-07-2007, 02:58 PM
I had tested both of them /var/spool/cron/root /etc/crontab They also did not run.

Posted by SmartTux, 08-07-2007, 03:02 PM
What do you get when you run the following on shell ? php -q /path/to/script/crontest.php OR /usr/local/bin/php -q /path/to/script/crontest.php

Posted by kamcm, 08-07-2007, 03:05 PM
If i type in #> php -q /path/to/script/crontest.php via SSH. The script will run and I can received notification email. Kam

Posted by SmartTux, 08-07-2007, 03:10 PM
Does the cron log show any error for this certain cron ? Do you get any error via email as to why it didnt run ? Another alternative is to create a file with just : #!/bin/bash /usr/local/bin/php -q /path/to/script/crontest.php Chmod to 7 and add to cron as "bash scriptname"

Posted by kamcm, 08-07-2007, 03:33 PM
This alternative method is work, Thank you for helping Kam

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Installing gd (Views: 251)
A question (Views: 262)