QUESTION Scheduled Reboot on IncrediblePBX 13-13 Raspberry Pi

Discussion in 'Open Discussion' started by mattburris, Jun 12, 2018.

  1. mattburris

    mattburris New Member

    Joined:
    Dec 22, 2017
    Messages:
    17
    Likes Received:
    2
    So I'd like my pbx to restart every night at 4am by calling /usr/local/sbin/reboot via cron

    As a test, I've set it up to reboot at 1:49pm.

    I use crontab to add the following line:

    49 13 * * * /bin/bash /usr/local/sbin/reboot

    at 1:49pm nothing happens.

    Any pointers?
     
  2. lrosenman

    lrosenman Guru

    Joined:
    Oct 17, 2014
    Messages:
    217
    Likes Received:
    30
    what user is running that cronjob?

    You need it to be root, or at least sudo without password.
     
  3. mattburris

    mattburris New Member

    Joined:
    Dec 22, 2017
    Messages:
    17
    Likes Received:
    2
    I am ssh'd into the RPi as root when I run 'crontab -e'

    Is there a way to check if any errors or logs are created when the job should run?
     
  4. lrosenman

    lrosenman Guru

    Joined:
    Oct 17, 2014
    Messages:
    217
    Likes Received:
    30
    It should mail root with any output.

    that said, check /var/log/cron for messages as well.
     
  5. kyle95wm

    kyle95wm Phone Genius Owner

    Joined:
    Apr 16, 2016
    Messages:
    404
    Likes Received:
    75
    That cronjob doesn't look right. Try this one:

    Code:
    49 13 * * * root reboot
    This will run a cronjob as root and will issue the reboot command. If that doesn't work. let me know.
     
  6. lrosenman

    lrosenman Guru

    Joined:
    Oct 17, 2014
    Messages:
    217
    Likes Received:
    30
    If that's in /etc/crontab that's correct, if it's in crontab -e (root's /var/spool/cron/tabs/root) his is correct
    and I just noticed that the reboot command is full path'd to /usr/local/sbin/reboot which is wrong.

    it's in /sbin/reboot..

    so make the crontab entry:
    49 13 * * * /sbin/reboot

    as it's NOT a shell script....
     
    kyle95wm likes this.
  7. mattburris

    mattburris New Member

    Joined:
    Dec 22, 2017
    Messages:
    17
    Likes Received:
    2
    I believe when I execute the 'reboot' command normally, is it running the file here: /usr/local/sbin/reboot?
    It's content is
    Code:
    #!/bin/bash
    
    fwconsole stop
    /etc/init.d/mysql stop
    /etc/init.d/apache2 stop
    shutdown -r now
    That particular file is the one I'd like to execute via cron to reboot the RPi.

    Correct me if I'm wrong, but I was under the impression that script should be used since it is gracefully shutting down Asterisk, mysql, and apache.
     
  8. kyle95wm

    kyle95wm Phone Genius Owner

    Joined:
    Apr 16, 2016
    Messages:
    404
    Likes Received:
    75
    Does "which reboot" return the path of the file you mentioned? If so, you should be able to execute the reboot command inside of cron.
     
    mattburris likes this.
  9. mattburris

    mattburris New Member

    Joined:
    Dec 22, 2017
    Messages:
    17
    Likes Received:
    2
    That works Kyle. Thanks!
     

Share This Page