ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Another Cron issue - reboot

    IT Discussion
    4
    5
    160
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      hobbit666
      last edited by

      Wonder why my simple reboot in Cron tab doesn't work.

      00 16 * * * /sbin/shutdown -r now

      Also tried Just

      reboot

      Adding the user to sudoers.d

      Using
      Ubuntu Mate 18.04 setup with a user called "display1"

      I 1 Reply Last reply Reply Quote 1
      • I
        IRJ @hobbit666
        last edited by

        @hobbit666 said in Another Cron issue - reboot:

        Wonder why my simple reboot in Cron tab doesn't work.

        00 16 * * * /sbin/shutdown -r now

        Also tried Just

        reboot

        Adding the user to sudoers.d

        Using
        Ubuntu Mate 18.04 setup with a user called "display1"

        Run as root and initiate a script that runs reboot . I would avoid using now as it will just stop everything and could crash services.

        So do something create a sh file like this with reboot command and put to script file
        vi /etc/scripts/reboot.sh

        1 Reply Last reply Reply Quote 4
        • D
          DustinB3403
          last edited by

          Cron runs scripts, while it can run commands, it's easier to just script what you want done.

          1 Reply Last reply Reply Quote 2
          • H
            hobbit666
            last edited by

            @IRJ @DustinB3403 will give that a try tomorrow if I get a chance otherwise Sunday

            S 1 Reply Last reply Reply Quote 0
            • S
              scottalanmiller @hobbit666
              last edited by

              @hobbit666 said in Another Cron issue - reboot:

              @IRJ @DustinB3403 will give that a try tomorrow if I get a chance otherwise Sunday

              Don't do it as a user, as IRJ says. This is because Cron does not use sudo. That would not make sense, if you dig into it.

              Here is why....

              1. The reason you put a cron job under a user is to act as that user. If cron tried to sudo, you'd lose the ability for users with sudo access to act as themselves, compromising security and limiting functionality.

              2. Any user with sudo access to root can put the cron job that they want directly under root itself, so #1 doesn't limit their functionality in any way, it only gives them more functionality.

              3. If it used sudo, tracking down where root level things were happening would become enormously difficult, instead of being centralized.

              1 Reply Last reply Reply Quote 2
              • 1 / 1
              • First post
                Last post