简体   繁体   中英

How can I debug a PHP CRON script that does not appear to be running?

I am trying to setup a CRON job using PHP, but am not having any luck so far.

I am following this tutorial: PHP - Create a Cron Job with PHP (dead link)

I have created the script file with the correct permissions, but the script is not being processed.

Any ideas?

Maybe your cron daemon isn't running? The daemon "crond" have to run on startup.

Check this with "ps -efc |grep crond"

Little checklist:

  1. Is your cron running -> u2ix [checked]
  2. Permissions to use cron [checked]
  3. Does your script run in the shell [checked i hope]
  4. Run a litte script that shows you the environmet in your cron (-> env) / it is never the same as in your shell :-)
  5. after execute your php-creat-cronjob-script check with corntab -l the crontab

-- do you get mail from your cron ?

it seems you could have any number of issues here.

Firstly have you checked that the file runs successfully from the command line?

if so another simple solution to the problem could be if you didn't set the file to be added correctly in $command so this could be pointing to a file you don't have.

Also checking that to cron file you have specified matches the directory referenced in these lines:

    // this will reinstate your Cron job

    exec("crontab /Users/vin/Sites/site/cron/Feed_cron"); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM