Cron not triggered

Discussion in 'Installation/Configuration' started by Stelios, Nov 15, 2020.

Tags:
  1. Stelios

    Stelios Active Member HowtoForge Supporter

    Hi,

    On a multi-server setup and 3.2.1 the cron jobs that are added via the GUI are not working. Adding a cronjob from the terminal with crontab -e is working fine; they just don't triggered.

    Example cron that I got to run at:
    0 9 * * * php -q /var/www/clients/client1/web52/web/crons/cron.php

    When I run it from terminal like:
    sudo -u web52 php -q /var/www/clients/client1/web52/web/crons/cron.php

    It works fine, no errors at all; it just doesn't triggered through cron.
    Same is happening for any cronjob that I'm adding via the GUI.

    I've enabled to log the output but there is nothing in the log files (empty):
    /var/www/clients/client1/web52/private/cron_error.log
    /var/www/clients/client1/web52/private/cron.log

    Any help is very much appreciated.
     
    Last edited: Nov 15, 2020
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    I'm sure it is triggered by cron, unless you have managed to break your system very badly. If cron no longer starts jobs you would surely have lots of stuff failing.
    What is more likely to happen is cron "triggers" the job, but it fails for some reason. I do not use the ISPConfig GUI to run cron jobs, so I do not know how to debug it except the GUI has Log output box to tick.
    Possible reasons for failing are no PHP in PATH of the cron job, or some other command. ISPConfig Manual explains what is different between shell cron and URL cron.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Post the cron file that ISPConfig created. My guess is you created a jailed cron without having PHP installed in the jail or something similar.
     
  4. Stelios

    Stelios Active Member HowtoForge Supporter

    @till where is that cron file saved?
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    /etc/cron.d/
     
  6. Stelios

    Stelios Active Member HowtoForge Supporter

    Here is the output:

    Code:
    root@web2:/etc/cron.d# cat ispc_web52
    MAILTO=''
    SHELL='/bin/sh'
    
    */30    *    *    *    *    web52    php -q /var/www/clients/client1/web52/web/crons/cron.php >>/var/www/clients/client1/web52/private/cron.log 2>>/var/www/clients/client1/web52/private/cron_error.log
    
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    ok, this cronjob is not jailed, so that's fine. But you must use the full path to PHP in a cronjob, so the command has to be:

    /usr/bin/php -q /var/www/clients/client1/web52/web/crons/cron.php

    as cron does not know where to find the php binary, as it does not use the $PATH variable.
     
  8. Stelios

    Stelios Active Member HowtoForge Supporter

    Thanks for the explanation Till; I wasn't aware that I have to put the whole path.
     

Share This Page