Cron Job Questions

Discussion in 'Installation/Configuration' started by abintipl, Apr 18, 2023.

  1. abintipl

    abintipl Member HowtoForge Supporter

    Hello,

    I am trying to set up a cron job for one of the web application on VPS with perfect server
    Under sites, I have set up a cron job as under;
    /usr/bin/php /var/www/mydomain.com/artisan schedule:run >> /dev/null 2>&1
    Then if I go command line to check crontab -e it shows like this;
    15 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
    * * * * * /usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    * * * * * /usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    30 23 * * * /usr/local/ispconfig/server/scripts/handle_mailbox_soft_deleted.sh &> /dev/null

    Here it does not show the Cror job I created & saved under sites.

    My first question is
    Do I need to add here after I run crontab -e & make it like this
    15 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
    * * * * * /usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    * * * * * /usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    30 23 * * * /usr/local/ispconfig/server/scripts/handle_mailbox_soft_deleted.sh &> /dev/null
    * * * * * /usr/bin/php /var/www/mydomain.com/artisan schedule:run >> /dev/null 2>&1

    if yes, then it does not work

    I tried
    root@app:~# sudo systemctl status cron
    ● cron.service - Regular background program processing daemon
    Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
    Active: active (running) since Tue 2023-04-18 02:21:59 EDT; 12h ago
    Docs: man:cron(8)
    Main PID: 373 (cron)
    Tasks: 1 (limit: 9477)
    Memory: 34.4M
    CGroup: /system.slice/cron.service
    └─373 /usr/sbin/cron -f

    Apr 18 14:58:01 app CRON[413944]: (root) CMD (/usr/bin/php /var/www/mydomain.com/artisan schedule:run >> /dev/null 2>&1)
    Apr 18 14:58:01 app CRON[413940]: pam_unix(cron:session): session opened for user web1 by (uid=0)
    Apr 18 14:58:01 app CRON[413945]: (root) CMD (/usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done)
    Apr 18 14:58:01 app CRON[413946]: (web1) CMD (/usr/bin/php /var/www/mydomain.com/artisan schedule:run >> /dev/null 2>&1 #mydomain.com)
    Apr 18 14:58:01 app CRON[413948]: (root) CMD (/usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/l>
    Apr 18 14:58:01 app jk_chrootsh[413946]: abort, homedir '/var/www/clients/client1/web1' for user web1 (5004) does not contain the jail separator <jail>/./<home>
    Apr 18 14:58:01 app CRON[413940]: pam_unix(cron:session): session closed for user web1
    Apr 18 14:58:01 app CRON[413941]: pam_unix(cron:session): session closed for user root
    Apr 18 14:58:01 app CRON[413943]: pam_unix(cron:session): session closed for user root
    Apr 18 14:58:01 app

    Where am I doing wrong? anything to do with chroot, how & what command
    Please help!
    Thanks & regards
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Website cronjobs are in /etc/cron.d/ directory, you can not view them by using crontab -e command. What you checked with crontab -e is the crontab of the root user, it would be a real security issue if website cronjobs would be run as root and not as website user.

    Your issue might be related to chroot, but first, you should check what the actual cronjob looks like in /etc/cron.d/
    When enabling chroot, you must use paths that are correct to the new root, so e.g. a file /var/www/somedomain/web/abc is now just /web/abc in the chroot.
     
  3. abintipl

    abintipl Member HowtoForge Supporter

    Dear Sir,
    Thank you for your reply.
    my /etc/cron.d/ has one of the following file;
    ispc_chrooted_web1
    MAILTO=''
    SHELL='/usr/sbin/jk_chrootsh'

    * * * * * web1 /usr/bin/php /var/www/mydomain.com/artisan schedule:run >> /dev/null 2>&1 #mydomain.com

    Further, please advice, how & where to enable chroot
    Thanks & regards,
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Chroot is already enabled, so the path in your command is wrong, use:

    /usr/bin/php /artisan schedule:run

    and double-check if artisan is really in the folder /var/www/mydomain.com/artisan and not in the web folder /var/www/mydomain.com/web/artisan, which you'd mean your cron command has to be:

    /usr/bin/php /web/artisan schedule:run
     

Share This Page