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

前端 未结 3 1568
庸人自扰
庸人自扰 2020-12-11 21:10

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 ha

相关标签:
3条回答
  • 2020-12-11 21:29

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

    Check this with "ps -efc |grep crond"

    0 讨论(0)
  • 2020-12-11 21:38

    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 ?

    0 讨论(0)
  • 2020-12-11 21:47

    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"); 
    
    0 讨论(0)
提交回复
热议问题