Problem getting cron job to run and in need of help :)

Discussion in 'General' started by MrCompTech, Jul 24, 2010.

  1. MrCompTech

    MrCompTech New Member

    The website is "infiniteresponder.mrcomptech.com".
    The cron job I created is :

    Code:
    *       *       *       *       *       web14   /usr/bin/php web/sendmails.php > /dev/null
    I have confirmed that web14 is for "infiniteresponder.mrcomptech.com".

    Running this from a SSH connection as mct_infres, the ssh user for infiniteresponder.mrcomptech.com works.
    Code:
    /usr/bin/php web/sendmails.php > /dev/null
    After logging in as mct_infres the PWD is "/var/www/clients/client1/web14"
    running ls -l as mct_infres:
    Code:
    dr-xr-xr-x 2 web14 client1 4096 Jul 22 20:09 bin
    drwxr-x--x 2 web14 client1 4096 Jul 22 16:27 cgi-bin
    drwxr-xr-x 2 web14 client1 4096 Jul 22 20:09 dev
    drwxr-xr-x 3 root  root    4096 Jul 22 20:39 etc
    drwxr-xr-x 3 web14 client1 4096 Jul 22 20:09 home
    dr-xr-xr-x 3 web14 client1 4096 Jul 22 20:09 lib
    dr-xr-xr-x 2 web14 client1 4096 Jul 22 20:09 lib64
    lrwxrwxrwx 1 web14 client1   57 Jul 22 16:27 log -> /var/log/ispconfig/httpd/infiniteresponder.mrcomptech.com
    drwxr-x--x 2 web14 client1 4096 Jul 22 16:27 ssl
    drwxrwxrwx 2 web14 client1 4096 Jul 23 17:40 tmp
    drwxr-xr-x 7 root  root    4096 Jul 22 20:09 usr
    drwxr-xr-x 3 root  root    4096 Jul 22 20:09 var
    drwx--x--- 7 web14 client1 4096 Jul 22 21:59 web
    After creating the cron job and then running server.sh I get this error twice:
    Code:
    ERROR: /var/www/clients/client1/web14/bin is not owned by root:root!
    This is correct, user web14 and group client1 own this folder.
    I thought this should be running as web14 not root, so I don't understand what is happenging here.
    If I try making the owner and group root:root then things just get worse.
    Here is the complete debug output after creating the cron job and running server.sh:
    Code:
    23.07.2010-19:43 - DEBUG - Set Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
    23.07.2010-19:43 - DEBUG - Found 1 changes, starting update process.
    23.07.2010-19:43 - DEBUG - Call function 'insert' in plugin 'cron_jailkit_plugin' raised by event 'cron_insert'.
    23.07.2010-19:43 - DEBUG - exec: chmod 755 /var/www/clients/client1/web14
    23.07.2010-19:43 - DEBUG - exec: chown root:root /var/www/clients/client1/web14
    ERROR: /var/www/clients/client1/web14/bin is not owned by root:root!
    23.07.2010-19:43 - DEBUG - Added programs to jailkit chroot with command: /usr/local/ispconfig/server/scripts/create_jailkit_programs.sh /var/www/clients/client1/web14 '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /bin/basename /usr/bin/dirname /usr/bin/nano'
    ERROR: /var/www/clients/client1/web14/bin is not owned by root:root!
    23.07.2010-19:43 - DEBUG - Added cron programs to jailkit chroot with command: /usr/local/ispconfig/server/scripts/create_jailkit_programs.sh /var/www/clients/client1/web14 '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php'
    usermod: no changes
    23.07.2010-19:43 - DEBUG - Added jailkit user to chroot with command: /usr/local/ispconfig/server/scripts/create_jailkit_user.sh web14 /var/www/clients/client1/web14 /home/web14 /bin/bash
    usermod: unlocking the user's password would result in a passwordless account.
    You should set a password with usermod -p to unlock this user's password.
    23.07.2010-19:43 - DEBUG - exec: chmod 755 /var/www/clients/client1/web14
    23.07.2010-19:43 - DEBUG - exec: chown root:root /var/www/clients/client1/web14
    23.07.2010-19:43 - DEBUG - Jailkit Plugin (Cron) -> insert username:web14
    23.07.2010-19:43 - DEBUG - Call function 'insert' in plugin 'cron_plugin' raised by event 'cron_insert'.
    23.07.2010-19:43 - DEBUG - Deleted Cron file /etc/cron.d/ispc_web14
    23.07.2010-19:43 - DEBUG - Wrote Cron file /etc/cron.d/ispc_chrooted_web14 with content:
    MAILTO=''
    
    SHELL='/usr/sbin/jk_chrootsh'
    
    *       *       *       *       *       web14   /usr/bin/php web/sendmails.php > /dev/null
    
    23.07.2010-19:43 - DEBUG - Processed datalog_id 526
    23.07.2010-19:43 - DEBUG - Remove Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
    finished.
    And in the System Log I get this repeated every minute until deleting the cron job:
    Code:
    Jul 23 19:46:01 prl-ofc-s01 jk_chrootsh[27195]: path /var/www/clients/client1/web14/dev/ is not owned by user 0
    Jul 23 19:46:01 prl-ofc-s01 jk_chrootsh[27195]: path /var/www/clients/client1/web14/dev/ is not owned by group 0
    Jul 23 19:46:01 prl-ofc-s01 jk_chrootsh[27195]: abort, /var/www/clients/client1/web14 is not a safe chroot jail.
    And from reading another similar thread I created both ftp and ssh users for this web site, but that has not corrected the problem.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The path web/sendmails.php is wrong. You have to use the absolute path to the script starting with a /

    You seem to have added a folder dev in /var/www/clients/client1/web14 which is not owned by root and this prevents the creation of the cronjob jail. Remove this folder or chown it to root.
     
  3. MrCompTech

    MrCompTech New Member

    Is there a way to run a users cron job from the command prompt?

    I changed the path in the cron job and chown the dev directory to root.
    I did not create the /var/www/clients/client1/web14/dev/ folder.
    I looked closer at the output below and can see were the system created these folders.

    I have four web sites for this client and only one had a cron job created for it, infiniteresonder.mrcomptech.com --> web14.
    And that is the only web site that has 'extra' folders in it.

    The other three have these folders:
    cgi-bin, log (symlink), ssl, tmp and web

    But the site that I created the cron job for has these additional folders, none of which I created:
    bin, dev, etc, home, lib, lib64, usr, var

    Working in the /var/www/clients/client1/web14/ folder -

    I chown on dev then it says group 0 does not own dev so I 'chgrp root dev'.
    Then an error in the system-log says that 'bin' is not owned by root:root, so I changed it that same way.
    Then yet another error for anothe "extra" folder has the same error.
    So all the extra folder I made the chown:chgrp root:root.

    After making these changes I deleted the cron job, ran server.sh, recreated the cron job ran server.sh again and this is what I got:

    Code:
    [root@prl-ofc-s01 client1]# /usr/local/ispconfig/server/server.sh
    24.07.2010-14:08 - DEBUG - Set Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
    24.07.2010-14:08 - DEBUG - Found 1 changes, starting update process.
    24.07.2010-14:08 - DEBUG - Call function 'insert' in plugin 'cron_jailkit_plugin' raised by event 'cron_insert'.
    24.07.2010-14:08 - DEBUG - exec: chmod 755 /var/www/clients/client1/web14
    24.07.2010-14:08 - DEBUG - exec: chown root:root /var/www/clients/client1/web14
    24.07.2010-14:08 - DEBUG - Added programs to jailkit chroot with command: /usr/local/ispconfig/server/scripts/create_jailkit_programs.sh /var/www/clients/client1/web14 '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /bin/basename /usr/bin/dirname /usr/bin/nano'
    24.07.2010-14:09 - DEBUG - Added cron programs to jailkit chroot with command: /usr/local/ispconfig/server/scripts/create_jailkit_programs.sh /var/www/clients/client1/web14 '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php'
    usermod: no changes
    24.07.2010-14:09 - DEBUG - Added jailkit user to chroot with command: /usr/local/ispconfig/server/scripts/create_jailkit_user.sh web14 /var/www/clients/client1/web14 /home/web14 /bin/bash
    usermod: unlocking the user's password would result in a passwordless account.
    You should set a password with usermod -p to unlock this user's password.
    24.07.2010-14:09 - DEBUG - exec: chmod 755 /var/www/clients/client1/web14
    24.07.2010-14:09 - DEBUG - exec: chown root:root /var/www/clients/client1/web14
    24.07.2010-14:09 - DEBUG - Jailkit Plugin (Cron) -> insert username:web14
    24.07.2010-14:09 - DEBUG - Call function 'insert' in plugin 'cron_plugin' raised by event 'cron_insert'.
    24.07.2010-14:09 - DEBUG - Deleted Cron file /etc/cron.d/ispc_web14
    24.07.2010-14:09 - DEBUG - Wrote Cron file /etc/cron.d/ispc_chrooted_web14 with content:
    MAILTO=''
    
    SHELL='/usr/sbin/jk_chrootsh'
    
    *       *       *       *       *       web14   /usr/bin/php /web/sendmails.php > /dev/null
    
    24.07.2010-14:09 - DEBUG - Processed datalog_id 548
    24.07.2010-14:09 - DEBUG - Remove Lock: /usr/local/ispconfig/server/temp/.ispconfig_lock
    finished.
    This appears to be without error except for:
    Code:
    usermod: unlocking the user's password would result in a passwordless account.
    You should set a password with usermod -p to unlock this user's password.
    But the cron job still doesn't to run, I know this because when it runs I do not get the emails from the autoresponder.
    I logged in with the ssh account created for this website and tried to run what the cron job wold run.

    /usr/bin/php /web/sendmails.php > /dev/null, but without the " > /dev/null" so I could see the outout and the result was:

    Could not open input file: /web/sendmails.php

    So I ran /usr/bin/php web/sendmails.php (without the beginning /), and the e-mails were immediatley delivered to my inbox.

    To bring things some what back to a starting point I deleted the cron job, ran server.sh then recreated the cron job with the path as 'web/sendmails.php' re-ran server.sh, other than the 'usermod' issue above the script server.sh ran correctly.

    Still no joy, no e-mails

    Waited a couple of minutes for the System-Log in ISPConfig3 to update and the erro rmessage was:
    Code:
    path /var/www/clients/client1/web14/./home/web14 is not owned by user 5015
    5015 is web14, Which can be seen in the /etc/passwd file (vim /etc/passwd, then search for "/" 5015)
    So I but the "/" back in the path of the cron job and "chown web14:client1 home" while in the directory "/var/www/clients/client1/web14"

    Still no joy, so changed path in cron job to "./web/sendmails.php"
    Waited a about 10 minutes the checked the system log again.
    Error as still :
    Code:
    Jul 24 14:46:01 prl-ofc-s01 jk_chrootsh[22223]: path /var/www/clients/client1/web14/./home/web14 is not owned by user 5015
    Jul 24 14:46:01 prl-ofc-s01 jk_chrootsh[22223]: path /var/www/clients/client1/web14/./home/web14 is not owned by group 5005
    So ran "chown web14:client1 web14" after cd to "/var/www/clients/client1/web14/./home/"

    Again waiting a while for log file entries...

    Now in the system log:
    Code:
    Jul 24 15:21:01 prl-ofc-s01 jk_chrootsh[23681]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:22:01 prl-ofc-s01 jk_chrootsh[23760]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:23:01 prl-ofc-s01 jk_chrootsh[23798]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:24:01 prl-ofc-s01 jk_chrootsh[23838]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:25:01 prl-ofc-s01 jk_chrootsh[23890]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    And When I delete the cron job, run server.sh then recreate the cron job and re-run server.sh I now get no errors and not even the "usermod -p" command as the log indicated, even though I did NOT run the usermod -p command.

    So I changed the cron job back to "/usr/bin/php /web/sendmails.php > /dev/null", waited a while again.

    Still not getting the e-mails but if I log in via SSH as the web site user and run "/usr/bin/php web/sendmails.php" then I get 2 e-mails, I have them set to be sent every 3 minutes while testing.

    So, It seems that the cron job is running every minute as scheduled without errors. At least there were no errors at the command prompt when running server.sh as root just immediately after creating the cron job. And there are no errors in the ISPConfig3 System-Log. I have never seen any entries in the ISPConfig3 "ISPC Cron-Log".

    I edited this the cron job saved in "/etc/cron.d/ispc_chrooted_web14" to add an e-mail notification by
    changing MAILTO=''
    to MAILTO='[email protected]' which is the same account the autoresponder should be sending the test messages to.

    I have sent mail to and from this email address to both, accounts on this server and my yahoo.com e-mail account with no problems.

    Since making the MAILTO change the cron job has run several times as indicated by the System-Log entries:

    Code:
    Jul 24 15:46:01 prl-ofc-s01 jk_chrootsh[24929]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:47:01 prl-ofc-s01 jk_chrootsh[24971]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:48:01 prl-ofc-s01 jk_chrootsh[25004]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:49:01 prl-ofc-s01 jk_chrootsh[25033]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    Jul 24 15:50:01 prl-ofc-s01 jk_chrootsh[25063]: now entering jail /var/www/clients/client1/web14 for user web14 (5015)
    But I did not get any e-mails at all from the cron job.
    But again logging in as the ssh user for this website and runing "/usr/bin/php ./web/sendmails.php" which is very similar to the cron job I get the e-mails from the autoresponder.

    And just to be clear the cron job is currently "/usr/bin/php /web/sendmails.php > /dev/null" for the website "infiniteresponder.mrcomptech.com" which is for client1 user web14.

    To help with troubleshooting -
    Is there a way to manually run or trigger the cron job to run while at an ssh prompt for the website user?
     
  4. MrCompTech

    MrCompTech New Member

    Cron job appears to be missing

    When logged in as root and run 'crontab -l' to list cron jobs all that is listed is:
    Code:
    * * * * * /usr/local/ispconfig/server/server.sh &> /dev/null
    30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null
    When logged in as the website user and run 'crontab -l' to list cron jobs all that is listed is:
    Code:
    no crontab for web14
    So once every minute, the schedule of the cronjob in ISPConfig3 for the website I see in the log
    Code:
    now entering jail /var/www/clients/client1/web14 for user web14
    But actions that should be taken place by this cron job don't happen and I cannot find any errors to help me find the problem.
     
  5. MrCompTech

    MrCompTech New Member

    Cron jobs don't run even when logged in ssh as website user.

    I tried creating the cron job after logging in as the website user.

    crontab -e

    created job
    Code:
    *       *       *       *       *       /usr/bin/php ./web/sendmails.php > /dev/null
    But cron emails web site user error message:
    Code:
    Could not open input file: ./web/sendmails.php
    so tried changing job to
    Code:
    *       *       *       *       *       /usr/bin/php /web/sendmails.php > /dev/null
    and still get the same error
    Code:
    Could not open input file: /web/sendmails.php
    Running the command from the command prompt as the website user -
    Code:
    /usr/bin/php /web/sendmails.php
    results in
    Code:
    Could not open input file: /web/sendmails.php
    But running command at command prompt
    Code:
    /usr/bin/php ./web/sendmails.php
    works.

    Any help on getting cron jobs configured under ISPConfig3 would be greatly appreciated!
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Normally you run such a sendmail.php file like this as cronjob:

    /usr/bin/wget http://www.yourdomain.com/sendmail.php

    and not with the commandline php interpreter which might be unavailable in the jailed cron enviroment.
     
  7. MrCompTech

    MrCompTech New Member

    Solved - Problem getting cron job to run and in need of help

    The cron job:
    * * * * * /usr/bin/wget http://infiniteresponder.mrcomptech.com/sendmails.php
    does work!

    Thank You!!!!!!!

    I thought wget was just an ftp program and thought that after wget downloaded the file then it needs a command processor, in this case since wget is downloading a php script the command processor would be /usr/bin/php.

    I don't understand why this works, but it would seem that wget must be more than just an FTP program and has support for php.

    In the meantime I had create this cron job, which does work or course but it is being run as root.
    * * * * * /usr/bin/php /var/www/infiniteresponder.mrcomptech.com/web/sendmails.php > /dev/null

    I prefer putting the cron job in the 'Sites' tab since it's a convenient place to put all cron jobs.

    Thanks again Till!
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Basically wget is a commandline ftp and http downloader. as the file is requested trogh http, it is executed by apache before it gets delivered to wget.
     

Share This Page