Friday, May 2, 2008

Schedule weekly job with cron and PHP

Several approaches might work depending on hosting configuration. The most straightforward approach with panel is to find cron jobs icon and select standard or advance version. Both of them have same information - standard form has combo boxes vs entering number into textbox in advance form. That should be done for specifying date and time when job should be executed. First version of command line used for setting a job is:


php /path/to/script.php

Possible error is "No input file specified."


php /home/<myhomedir>/public_html/admin/job.php

Possible error is "No input file specified."


/usr/local/bin/php /home/<myhomedir>/public_html/admin/job.php

Possible error is "Could not open input file: /home/<myhomedir>/public_html/admin/job.php."


/usr/local/bin/php $HOME/public_html/admin/job.php

Last version of command line should work.