New cronjobs won't execute

Discussion in 'ISPConfig 3 Priority Support' started by Blaasbalg, Jun 30, 2014.

  1. Blaasbalg

    Blaasbalg Member

    Hi,

    I'm currently having some issues setting up new cronjobs on my server. Old cronjobs seem to work fine, new ones do not. I have no idea when this problem first started.

    The first website I created some months ago also has a couple of cronjobs assigned to it, which are working perfectly fine. However, any newly created cronjobs (for any website) refuse to execute (well, at least it appears like they don't execute - I created a task which should execute a test script which writes the results to a file in order to confirm whether it's working or not, unfortunately nothing is being written to the file (manually running the script works fine, so no problems there either)).

    The ISPConfig Cronjob log remains completely empty as well.

    The test cronjob looks like this:

    Code:
    *	*	*	*	*	/usr/bin/php /var/www/clients/client4/web21/web/test.php
    What could be the cause of this issue?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Please post the complete cronjob file from /etc/cron.d/ folder
     
  3. Blaasbalg

    Blaasbalg Member

    ispc_web21:

    Code:
    MAILTO=''
    SHELL='/bin/sh'
    
    */5     *       *       *       *       web21   /usr/bin/php /var/www/clients/client4/web21/web/support/api/cron.php #***.org
    *       *       *       *       *       web21   /usr/bin/php /var/www/clients/client4/web21/web/test.php #***.org
     
  4. Blaasbalg

    Blaasbalg Member

    Any ideas perhaps? :)
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Sorry, somehow missed your post. The cronjobs are looking fine, the cronjob is not jailed so php is available there.

    can you run the scripts manually as user web21 with:

    su web21
    /usr/bin/php /var/www/clients/client4/web21/web/support/api/cron.php
     
  6. Blaasbalg

    Blaasbalg Member

    'su web21' doesn't really seem to do anything (it won't change the current user). I also tried 'su - web21' instead, no luck there either.
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Hmm, works here. But this might be the case at my server because I have a shell user added in ispconfig for that website.
     
  8. Blaasbalg

    Blaasbalg Member

    I've tried doing that as well, without effect.

    Is there perhaps anything else I should check?
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok. Does the cronjob work when you run:

    /usr/bin/php /var/www/clients/client4/web21/web/support/api/cron.php

    as root user?

    And did you try to restart the cron daemon?

    Thats ok, this log is not used by website cronjobs, the log is only for errors that occur in ispconfig. So a empty log means that there are no errors in ispconfig.
     
  10. Blaasbalg

    Blaasbalg Member

    It seems to work fine when executed as the root user, yes. :)

    The server has been rebooted not long ago (while this problem was already present).
     
    Last edited: Jul 10, 2014
  11. Blaasbalg

    Blaasbalg Member

    Anything else I should check?
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    try to add a ssh user to that website in ispconfig ( a ssh user without chroot) and then login to the server with this ssh user and try to run the command from your crontab.
     
  13. Blaasbalg

    Blaasbalg Member

    That seems to work fine as well. :)
     
  14. Blaasbalg

    Blaasbalg Member

    This is pretty old, but unfortunately I stumbled upon this issue again today (it was never fixed, I simply forgot about this as it has always been working just fine for my main website and I wasn't really in need of cronjobs for other websites (and now I am) - I only discovered the issue at that time due to some testing of scripts).

    I've been digging around looking for the cause, and found this in the cron log files:

    Code:
    Jan 15 00:07:01 server2 CROND[14327]: (CRON) ERROR chdir failed (/var/www/clients/client4/web21/./home/web21): No such file or directory
    Which sheds some light on what's going on...

    I proceeded by looking up the home directory of the user 'web21':

    Code:
    /var/www/clients/client4/web21/./home/web21
    Which matches the path cron is trying to read from... but I still don't really understand why it's trying to read from the user's home directory instead of the path supplied in the actual cronjob... my initial thought was that this is due to Chrooted Crons, but I have cronjobs set to Full Cron (just for testing) for this particular user, so I guess that can't really be it?

    I feel like I am overlooking something, but I'm not sure what that is...
     
    Last edited: Jan 15, 2016
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    Can you please post the crontab file from /etc/cron.d/ of this cronjob?
     
  16. Blaasbalg

    Blaasbalg Member

    ispc_web21:
    Code:
    MAILTO=''
    SHELL='/bin/sh'
    
    *       *       *       *       *       web21   /usr/bin/php /var/www/clients/client4/web21/web/cron_test.php #*
     
  17. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats a non jailed job indeed, I dont see a reason why it fails here. Did you try to run the job as user web21 on the shell? e.g.:

    sudo -u web21 /usr/bin/php /var/www/clients/client4/web21/web/cron_test.php
     
  18. Blaasbalg

    Blaasbalg Member

    Running it on the shell seems to be working fine.

    Odd... I can't imagine why it's doing this :confused:
     
  19. till

    till Super Moderator Staff Member ISPConfig Developer

    Maybe you can try this, add a small shell script, e.g. /var/www/clients/client4/web21/private/cron.sh in the private folder of this website. in the script you add:

    Code:
    #!/bin/bash
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin
    . /etc/profile
    umask 022
    web21 /usr/bin/php /var/www/clients/client4/web21/web/cron_test.php
    make the script executable and chown it to the right user:

    chown web21:client4 cron.sh
    chmod +x cron.sh

    then change the cronjob to:

    /var/www/clients/client4/web21/private/cron.sh
     
  20. Blaasbalg

    Blaasbalg Member

    Code:
    Jan 15 14:47:01 server2 CROND[1819]: (CRON) ERROR chdir failed (/var/www/clients/client4/web21/./home/web21): No such file or directory
     

Share This Page