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" -
@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 usingnow
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
-
Cron runs scripts, while it can run commands, it's easier to just script what you want done.
-
@IRJ @DustinB3403 will give that a try tomorrow if I get a chance otherwise Sunday
-
@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....
-
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.
-
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.
-
If it used sudo, tracking down where root level things were happening would become enormously difficult, instead of being centralized.
-