Wednesday, April 24, 2024
 Popular · Latest · Hot · Upcoming
15
rated 0 times [  15] [ 0]  / answers: 1 / hits: 36874  / 2 Years ago, tue, march 15, 2022, 12:58:43

Using the terminal or a bash file, how can I configure Ubuntu to reboot every day at (say for instance) 3 AM?



In other words, I want to schedule an automatic reboot through the terminal.



I haven't been able to find anything related to this on Google or AskUbuntu, and I'm fairly new to Ubuntu in general (just got my new Raspberry Pi).


More From » bash

 Answers
5

Edit the crontab entries using crontab -e command (by default this will edit the current logged-in users crontab) and add the following line:



0 3 * * * echo $PASSWD | sudo -S reboot
#change $PASSWD with your password


Save the file and check the new crontab entry with crontab -l.



If you want to use only:



0 3 * * * sudo reboot


as crontab, this doesn't work normally and you should check this post to see how can you make it to work.



Or, simple add the crontab to the root user's crontab file offering the complete path for the reboot command using sudo crontab -e:



0 3 * * * /sbin/reboot

[#30133] Wednesday, March 16, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingssex

Total Points: 21
Total Questions: 122
Total Answers: 98

Location: Sweden
Member since Fri, Mar 26, 2021
3 Years ago
;