Join the community today
Become a Member

Cronjob Question

Discussion in 'System Administration' started by xaitmi, Feb 12, 2015.

  1. xaitmi

    xaitmi Member

    35
    3
    8
    Jan 18, 2015
    Ratings:
    +3
    Local Time:
    4:46 PM
    Hi I have CentMinMod running on centos 6 64bit

    I installed crontab and did crontab -e and added

    0 0 * * 0,1,2,3,4,5,6 php -q /home/nginx/domains/mydomain.com/public/admindir/cron.php >/dev/null 2>&1

    I want it to run cron.php everyday at midnight.

    It's been 4 days now and it has not run yet.

    Does anyone know why?

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    34,638
    7,656
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,774
    Local Time:
    6:46 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
  3. xaitmi

    xaitmi Member

    35
    3
    8
    Jan 18, 2015
    Ratings:
    +3
    Local Time:
    4:46 PM
  4. xaitmi

    xaitmi Member

    35
    3
    8
    Jan 18, 2015
    Ratings:
    +3
    Local Time:
    4:46 PM
  5. eva2000

    eva2000 Administrator Staff Member

    34,638
    7,656
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,774
    Local Time:
    6:46 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    what does cron log say ?

    Code:
    tail -100 /var/log/cron
     
  6. xaitmi

    xaitmi Member

    35
    3
    8
    Jan 18, 2015
    Ratings:
    +3
    Local Time:
    4:46 PM
    This

    Code:
    tail -100 /var/log/cron
    Feb 17 20:01:01 ub3 run-parts(/etc/cron.hourly)[13338]: starting 0anacron
    Feb 17 20:01:01 ub3 run-parts(/etc/cron.hourly)[13347]: finished 0anacron
    Feb 17 21:01:01 ub3 CROND[13542]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 17 21:01:01 ub3 run-parts(/etc/cron.hourly)[13542]: starting 0anacron
    Feb 17 21:01:01 ub3 run-parts(/etc/cron.hourly)[13551]: finished 0anacron
    Feb 17 22:01:01 ub3 CROND[13747]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 17 22:01:01 ub3 run-parts(/etc/cron.hourly)[13747]: starting 0anacron
    Feb 17 22:01:01 ub3 run-parts(/etc/cron.hourly)[13756]: finished 0anacron
    Feb 17 23:01:01 ub3 CROND[13940]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 17 23:01:01 ub3 run-parts(/etc/cron.hourly)[13940]: starting 0anacron
    Feb 17 23:01:01 ub3 run-parts(/etc/cron.hourly)[13949]: finished 0anacron
    Feb 18 00:00:01 ub3 CROND[14152]: (root) CMD (php -q /home/nginx/domains/my.ub3.com/public/admindir/cron.php)
    Feb 18 00:01:01 ub3 CROND[14164]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 00:01:01 ub3 run-parts(/etc/cron.hourly)[14164]: starting 0anacron
    Feb 18 00:01:01 ub3 anacron[14173]: Anacron started on 2015-02-18
    Feb 18 00:01:01 ub3 run-parts(/etc/cron.hourly)[14175]: finished 0anacron
    Feb 18 00:01:01 ub3 anacron[14173]: Jobs will be executed sequentially
    Feb 18 00:01:01 ub3 anacron[14173]: Normal exit (0 jobs run)
    Feb 18 00:45:01 ub3 CROND[14321]: (root) CMD (/usr/sbin/csf -u)
    Feb 18 01:01:01 ub3 CROND[14389]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 01:01:01 ub3 run-parts(/etc/cron.hourly)[14389]: starting 0anacron
    Feb 18 01:01:01 ub3 anacron[14398]: Anacron started on 2015-02-18
    Feb 18 01:01:01 ub3 anacron[14398]: Jobs will be executed sequentially
    Feb 18 01:01:01 ub3 anacron[14398]: Normal exit (0 jobs run)
    Feb 18 01:01:01 ub3 run-parts(/etc/cron.hourly)[14400]: finished 0anacron
    Feb 18 02:01:01 ub3 CROND[14593]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 02:01:01 ub3 run-parts(/etc/cron.hourly)[14593]: starting 0anacron
    Feb 18 02:01:01 ub3 anacron[14602]: Anacron started on 2015-02-18
    Feb 18 02:01:01 ub3 anacron[14602]: Jobs will be executed sequentially
    Feb 18 02:01:01 ub3 anacron[14602]: Normal exit (0 jobs run)
    Feb 18 02:01:01 ub3 run-parts(/etc/cron.hourly)[14604]: finished 0anacron
    Feb 18 03:01:01 ub3 CROND[14803]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 03:01:01 ub3 run-parts(/etc/cron.hourly)[14803]: starting 0anacron
    Feb 18 03:01:01 ub3 anacron[14812]: Anacron started on 2015-02-18
    Feb 18 03:01:01 ub3 anacron[14812]: Will run job `cron.daily' in 10 min.
    Feb 18 03:01:01 ub3 anacron[14812]: Jobs will be executed sequentially
    Feb 18 03:01:01 ub3 run-parts(/etc/cron.hourly)[14814]: finished 0anacron
    Feb 18 03:11:01 ub3 anacron[14812]: Job `cron.daily' started
    Feb 18 03:11:01 ub3 run-parts(/etc/cron.daily)[14849]: starting diskalert
    Feb 18 03:11:01 ub3 run-parts(/etc/cron.daily)[14881]: finished diskalert
    Feb 18 03:11:01 ub3 run-parts(/etc/cron.daily)[14849]: starting logrotate
    Feb 18 03:11:01 ub3 run-parts(/etc/cron.daily)[14888]: finished logrotate
    Feb 18 03:11:01 ub3 run-parts(/etc/cron.daily)[14849]: starting mlocate.cron
    Feb 18 03:11:02 ub3 run-parts(/etc/cron.daily)[14899]: finished mlocate.cron
    Feb 18 03:11:02 ub3 anacron[14812]: Job `cron.daily' terminated
    Feb 18 03:11:02 ub3 anacron[14812]: Normal exit (1 job run)
    Feb 18 04:01:01 ub3 CROND[15073]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 04:01:01 ub3 run-parts(/etc/cron.hourly)[15073]: starting 0anacron
    Feb 18 04:01:01 ub3 run-parts(/etc/cron.hourly)[15082]: finished 0anacron
    Feb 18 05:01:01 ub3 CROND[15319]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 05:01:01 ub3 run-parts(/etc/cron.hourly)[15319]: starting 0anacron
    Feb 18 05:01:01 ub3 run-parts(/etc/cron.hourly)[15328]: finished 0anacron
    Feb 18 06:01:01 ub3 CROND[15525]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 06:01:01 ub3 run-parts(/etc/cron.hourly)[15525]: starting 0anacron
    Feb 18 06:01:01 ub3 run-parts(/etc/cron.hourly)[15534]: finished 0anacron
    Feb 18 07:01:01 ub3 CROND[15742]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 07:01:01 ub3 run-parts(/etc/cron.hourly)[15742]: starting 0anacron
    Feb 18 07:01:01 ub3 run-parts(/etc/cron.hourly)[15751]: finished 0anacron
    Feb 18 08:01:01 ub3 CROND[15979]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 08:01:01 ub3 run-parts(/etc/cron.hourly)[15979]: starting 0anacron
    Feb 18 08:01:01 ub3 run-parts(/etc/cron.hourly)[15988]: finished 0anacron
    Feb 18 09:01:01 ub3 CROND[16207]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 09:01:01 ub3 run-parts(/etc/cron.hourly)[16207]: starting 0anacron
    Feb 18 09:01:01 ub3 run-parts(/etc/cron.hourly)[16216]: finished 0anacron
    Feb 18 10:01:01 ub3 CROND[16442]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 10:01:01 ub3 run-parts(/etc/cron.hourly)[16442]: starting 0anacron
    Feb 18 10:01:01 ub3 run-parts(/etc/cron.hourly)[16451]: finished 0anacron
    Feb 18 11:01:01 ub3 CROND[16669]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 11:01:01 ub3 run-parts(/etc/cron.hourly)[16669]: starting 0anacron
    Feb 18 11:01:01 ub3 run-parts(/etc/cron.hourly)[16678]: finished 0anacron
    Feb 18 12:01:01 ub3 CROND[16867]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 12:01:01 ub3 run-parts(/etc/cron.hourly)[16867]: starting 0anacron
    Feb 18 12:01:01 ub3 run-parts(/etc/cron.hourly)[16876]: finished 0anacron
    Feb 18 13:01:01 ub3 CROND[17094]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 13:01:01 ub3 run-parts(/etc/cron.hourly)[17094]: starting 0anacron
    Feb 18 13:01:01 ub3 run-parts(/etc/cron.hourly)[17103]: finished 0anacron
    Feb 18 14:01:01 ub3 CROND[17324]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 14:01:01 ub3 run-parts(/etc/cron.hourly)[17324]: starting 0anacron
    Feb 18 14:01:01 ub3 run-parts(/etc/cron.hourly)[17333]: finished 0anacron
    Feb 18 15:01:01 ub3 CROND[17563]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 15:01:01 ub3 run-parts(/etc/cron.hourly)[17563]: starting 0anacron
    Feb 18 15:01:01 ub3 run-parts(/etc/cron.hourly)[17572]: finished 0anacron
    Feb 18 16:01:01 ub3 CROND[17798]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 16:01:01 ub3 run-parts(/etc/cron.hourly)[17798]: starting 0anacron
    Feb 18 16:01:01 ub3 run-parts(/etc/cron.hourly)[17807]: finished 0anacron
    Feb 18 17:01:01 ub3 CROND[18032]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 17:01:01 ub3 run-parts(/etc/cron.hourly)[18032]: starting 0anacron
    Feb 18 17:01:01 ub3 run-parts(/etc/cron.hourly)[18041]: finished 0anacron
    Feb 18 18:01:01 ub3 CROND[18257]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 18:01:01 ub3 run-parts(/etc/cron.hourly)[18257]: starting 0anacron
    Feb 18 18:01:01 ub3 run-parts(/etc/cron.hourly)[18266]: finished 0anacron
    Feb 18 19:01:01 ub3 CROND[18483]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 19:01:01 ub3 run-parts(/etc/cron.hourly)[18483]: starting 0anacron
    Feb 18 19:01:01 ub3 run-parts(/etc/cron.hourly)[18492]: finished 0anacron
    Feb 18 20:01:01 ub3 CROND[18714]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 20:01:01 ub3 run-parts(/etc/cron.hourly)[18714]: starting 0anacron
    Feb 18 20:01:01 ub3 run-parts(/etc/cron.hourly)[18723]: finished 0anacron
    Feb 18 21:01:01 ub3 CROND[18914]: (root) CMD (run-parts /etc/cron.hourly)
    Feb 18 21:01:01 ub3 run-parts(/etc/cron.hourly)[18914]: starting 0anacron
    Feb 18 21:01:01 ub3 run-parts(/etc/cron.hourly)[18923]: finished 0anacron
     
  7. eva2000

    eva2000 Administrator Staff Member

    34,638
    7,656
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,774
    Local Time:
    6:46 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    log shows crond service running fine :)

    Code:
    Feb 18 00:00:01 ub3 CROND[14152]: (root) CMD (php -q /home/nginx/domains/my.ub3.com/public/admindir/cron.php)
     
  8. xaitmi

    xaitmi Member

    35
    3
    8
    Jan 18, 2015
    Ratings:
    +3
    Local Time:
    4:46 PM
    It says that but it's not actually running it on my billing system.

    If I run the cron manually by entering this url into my browser it runs fine and actually runs all the tasks.

    https://my.domain.com/admindir/cron.php
     
  9. eva2000

    eva2000 Administrator Staff Member

    34,638
    7,656
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,774
    Local Time:
    6:46 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    try running cronjob as nginx user and not root.. it's related to your php script so you'd have to work that out
     
  10. xaitmi

    xaitmi Member

    35
    3
    8
    Jan 18, 2015
    Ratings:
    +3
    Local Time:
    4:46 PM
    I found the problem.

    I made the cron output what goes on to pinpoint the issue

    50 20 * * * php -q /home/nginx/domains/my.domain.com/public/admindir/cron.php > /tmp/whatstheproblem.out 2>&1

    Then I opened whatstheproblem.out and it said this

    /bin/sh: php: command not found

    On Centminmod what should I use instead of php -q?

    --

    whereis php
    php: /usr/local/bin/php /usr/local/lib/php /usr/local/lib/php.ini /usr/local/php
     
  11. eva2000

    eva2000 Administrator Staff Member

    34,638
    7,656
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,774
    Local Time:
    6:46 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    try /usr/local/bin/php
     
    • Winner Winner x 1
  12. xaitmi

    xaitmi Member

    35
    3
    8
    Jan 18, 2015
    Ratings:
    +3
    Local Time:
    4:46 PM
    And we hit the jack pot :)
    It worked.

    57 20 * * * /usr/local/bin/php /home/nginx/domains/my.domain.com/public/admindir/cron.php > /tmp/output.out 2>&1
     
    Last edited: Feb 22, 2015
    • Like Like x 1
  13. Pansy

    Pansy New Member

    2
    0
    1
    Jan 11, 2015
    Ratings:
    +0
    Local Time:
    4:46 AM
    2
    MariaDB 5.5
    You can use any external cron(eg: easycron.com) try, which starts processes on the URL.
     
  14. elargento

    elargento Member

    332
    17
    18
    Jan 4, 2016
    Ratings:
    +42
    Local Time:
    5:46 PM
    10
    How do you do that?
     
  15. eva2000

    eva2000 Administrator Staff Member

    34,638
    7,656
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +11,774
    Local Time:
    6:46 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
..