Welcome to Centmin Mod Community
Register Now

PHP cronjob are not executed

Discussion in 'System Administration' started by Federico Liva, Apr 27, 2015.

  1. Federico Liva

    Federico Liva New Member

    5
    1
    3
    Apr 27, 2015
    Ratings:
    +1
    Local Time:
    1:10 PM
    This is the first time I configure a cron job in a VPS server, I always used some GUI like cPanel to do that. I need to configure a cron job of Sendy (FutureSpark - Ideas for the future to send the scheduled newsletters. The command is this:

    */5 * * * * php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1

    I used crontab -e to write that entry in the right place, and executing crontab -l my cronjob get listed.
    Using service crond status the cron deamon is running.

    Launching the php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php all works fine, but waiting for the cronjob doesn't run the script.


    What I'm wrong?
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,087
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:10 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    what is output of

    Code:
    crontab -l
    try specifying full path to php

    Code:
    which php
    /usr/local/bin/php
    Code:
    */5 * * * * /usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1
     
  3. Federico Liva

    Federico Liva New Member

    5
    1
    3
    Apr 27, 2015
    Ratings:
    +1
    Local Time:
    1:10 PM
    Specifying the full path still doesn't work. This is the output of crontab -l

    */5 * * * * /usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1

    I've gived a look on /etc/crontab and that command is not present. It's relevant?
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,087
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:10 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    /etc/crontab not relevant just crontab -l output should be enough to see if cronjob is there

    check your /var/log/cron log for entries

    Code:
    tail -100 /var/log/cron
    filter for your script
    Code:
    tail -100 /var/log/cron | grep scheduled.php
     
  5. Federico Liva

    Federico Liva New Member

    5
    1
    3
    Apr 27, 2015
    Ratings:
    +1
    Local Time:
    1:10 PM
    That the output of the log:

    Apr 27 03:40:01 architetturaecosostenibile CROND[2883]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 03:45:01 architetturaecosostenibile CROND[2908]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 03:50:01 architetturaecosostenibile CROND[2933]: (root) CMD (nginx php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 03:55:01 architetturaecosostenibile CROND[2956]: (root) CMD (root php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:00:01 architetturaecosostenibile CROND[3001]: (root) CMD (root php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:05:01 architetturaecosostenibile CROND[3035]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:10:01 architetturaecosostenibile CROND[3078]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:15:01 architetturaecosostenibile CROND[3098]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:20:01 architetturaecosostenibile CROND[3123]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:25:01 architetturaecosostenibile CROND[3141]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:30:01 architetturaecosostenibile CROND[3161]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:35:01 architetturaecosostenibile CROND[3200]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:40:01 architetturaecosostenibile CROND[3218]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:45:01 architetturaecosostenibile CROND[3236]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:50:01 architetturaecosostenibile CROND[3251]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 04:55:01 architetturaecosostenibile CROND[3270]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:00:01 architetturaecosostenibile CROND[3287]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:05:01 architetturaecosostenibile CROND[3317]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:10:01 architetturaecosostenibile CROND[3337]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:15:01 architetturaecosostenibile CROND[3357]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:20:01 architetturaecosostenibile CROND[3374]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:25:01 architetturaecosostenibile CROND[3392]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:30:01 architetturaecosostenibile CROND[3408]: (root) CMD (php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:35:01 architetturaecosostenibile CROND[3472]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:40:01 architetturaecosostenibile CROND[3490]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:45:01 architetturaecosostenibile CROND[3511]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:50:01 architetturaecosostenibile CROND[3530]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 05:55:01 architetturaecosostenibile CROND[3547]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:00:01 architetturaecosostenibile CROND[3564]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:05:01 architetturaecosostenibile CROND[3593]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:10:01 architetturaecosostenibile CROND[3612]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:15:01 architetturaecosostenibile CROND[3630]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:20:01 architetturaecosostenibile CROND[3663]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:25:01 architetturaecosostenibile CROND[3683]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:30:01 architetturaecosostenibile CROND[3699]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:35:01 architetturaecosostenibile CROND[3740]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)
    Apr 27 06:40:01 architetturaecosostenibile CROND[3755]: (root) CMD (/usr/local/bin/php /home/nginx/domains/nl.architetturaecosostenibile.it/public/scheduled.php > /dev/null 2>&1)

    It seems are executed?
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,087
    12,177
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,735
    Local Time:
    11:10 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yup it's running every 5 minutes according to cron log

    in future you can wrap such output in [CODE][/CODE] tags ;)
     
  7. Federico Liva

    Federico Liva New Member

    5
    1
    3
    Apr 27, 2015
    Ratings:
    +1
    Local Time:
    1:10 PM
    Sorry for the missed tags! It works now. Incredible. We have changed only the php path!