Cron Job outside of ISPconfig?

Discussion in 'ISPConfig 3 Priority Support' started by JohnnyBeGood, Jun 27, 2018.

  1. JohnnyBeGood

    JohnnyBeGood Member

    Hello,

    I have Liquidsoap on the same server image that I got from here Ubuntu 16.04 and even after I setup cron job as specific username (Administrator) to restart it does not run on the specific time yet when I run it from Webmin "Scheduled Cron Jobs" it restarts just fine. Any idea?
    TIA
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Cronjobs outside of ISPConfig are no problem, just add them as usual. I doubt that the user Administrator is allowed to restart the service. Add the cronjob to run as root user.
     
  3. JohnnyBeGood

    JohnnyBeGood Member

    Sorry for late reply but I got really busy with some personal stuff.

    I've tried with root and administrator but neither one will run at specific time only if i click on "Save and Run Now" https://prnt.sc/k84khb
    Cron job log file /var/log/syslog at ie. 12:59 shows this:
    Code:
    Jul 18 12:59:01 ubuntu cron[989]: (root) RELOAD (crontabs/root)
    Jul 18 12:59:01 ubuntu CRON[13855]: (root) CMD (/etc/init.d/liquidsoap restart #liquidsoap restart)
    Jul 18 12:59:01 ubuntu CRON[13856]: (root) CMD (/usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done)
    Jul 18 12:59:01 ubuntu CRON[13876]: (root) CMD (/usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done)
    Jul 18 12:59:01 ubuntu postfix/pickup[29127]: B24801FF1F: uid=0 from=<root>
    
    Here's output of date before that 12:59 https://prnt.sc/k84jqq
     
    Last edited: Jul 18, 2018
  4. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    I only remember Debian 7 or 8 having some serious issue at one minor release where you had to restart cronjob service to make it work again... but dunno what situation you have there.
    I don't know liquidsoap either nor what it does to the system ... though everything would be a wild guess :(
     
  5. JohnnyBeGood

    JohnnyBeGood Member

    Thanks for the reply! To sum it up, restarting, stopping or starting runs from the command line just fine AND when clicking on "Save and Run Now" just not at specific time using cronjob.
     
  6. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    have you investigated wether the created cronfiles are actually valid?
    I don't know how! the cronjob is executed when the process knows to run them just now, maybe
     
  7. JohnnyBeGood

    JohnnyBeGood Member

    I've searched online but could not find that info :(
     
  8. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Maybe the the crontab is wrong? You have not shown what is in the crontab.
    Code:
    crontab -l
     
  9. JohnnyBeGood

    JohnnyBeGood Member

    It looks like that it matches my previous screenshot?
    Code:
    [root@ubuntu ~]# crontab -l
    * * * * * /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
    2 * 7,14,18,21,28 * * /etc/init.d/liquidsoap stop #liquidsoap stop
    [root@ubuntu ~]#
     
  10. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    That should run 2 minutes after each full hour at the
    7,14,18,21,28 days of month. Strange schedule, is that what you want?
    What is that
    #liquidsoap stop
    in the cron command doing? Looks to me it makes the command invalid.
     
    ztk.me likes this.
  11. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Edit the file with command
    Code:
    crontab -e
    to fix that possible invalid command. Add in the file the line
    so you get emailed info if the command cron executes outputs something, error messages for example.
     
    ztk.me likes this.
  12. JohnnyBeGood

    JohnnyBeGood Member

    The reason for schedule was to testing purpose instead of waiting another weak to see if it will work.
    That is description of the command https://prnt.sc/k8y1zt
    Stop command is also for testing purpose just to see if it will execute it.

    I even went more extreme and set it at all minutes, days and months but even after I added
    [email protected] I'm not getting any emails. No trace of it in the mail log /var/log/mail.log
     
  13. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Mail gets sent only if cron job outputs something.
    That description is irrelevant. What matters is what crontab -l shows.
     
  14. JohnnyBeGood

    JohnnyBeGood Member

    But syslog shows that every minute cron job is run.

    Code:
    Jul 20 09:31:01 ubuntu CRON[20519]: (root) CMD (/usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done)
    Jul 20 09:31:01 ubuntu CRON[20520]: (root) CMD (/etc/init.d/liquidsoap stop)
    Jul 20 09:31:01 ubuntu CRON[20521]: (root) CMD (/usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done)
    
    and here
    Code:
    Jul 20 09:30:01 ubuntu CRON[19695]: (getmail) CMD (/usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null)
    Jul 20 09:30:01 ubuntu CRON[19697]: (root) CMD (/etc/init.d/liquidsoap stop)
    Jul 20 09:30:01 ubuntu CRON[19704]: (root) CMD (/usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done)
    Jul 20 09:30:01 ubuntu CRON[19715]: (root) CMD (/usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done)
    
    and so on...
     
  15. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Try cron job like something like this:
    Code:
    * * * * * /bin/date
     
  16. JohnnyBeGood

    JohnnyBeGood Member

    Code:
    root@ubuntu:~# crontab -l
    * * * * * /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
    * * * * * /etc/init.d/liquidsoap stop
    * * * * * /bin/date
    [email protected]
    root@ubuntu:~#
    
    Hmm, still not getting any email :(
    If I click on save and run now in Webmin I get correct output https://prnt.sc/k8z4bj
     
  17. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Does sending mail work on that host?
    Does command
    Code:
    mailx
    show emails? Either as root or the user created at install time.
     
  18. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Put that MAILTO line first in the crontab.
    Is cron running on that host at all? Are the changes made in ISPConfig panel going OK? Try cron line
    Code:
    * * * * * env > /tmp/env.txt
    and see if file /tmp/env.txt appears and what is in it.
     
  19. JohnnyBeGood

    JohnnyBeGood Member

    It does. Since this is test server I guess I never tested email sending on it.
    Here's the end output.

    Code:
    New mail has arrived.
    Saved 2 messages in /root/mbox
    Held 755 messages in /var/mail/root
    You have mail in /var/mail/root
    root@ubuntu:~#
    
     

Share This Page