How to automatically reboot my server every 4 hours?
10,490
The crontab
Method
- Open your Terminal or SSH into your server
- Type
sudo crontab -e
and the press ENTER - Use the down arrow key to go to the bottom of the text
- Type
0 */4 * * * sudo reboot
- Press CTRL+X
- Press Y
- Press ENTER
If all went well, it should reboot every 4 hours, on the hour.
Related videos on Youtube
Author by
G. Macasero
Updated on September 18, 2022Comments
-
G. Macasero over 1 year
I need help with my dedicated Ubuntu server.
How can I reboot my server every 4 hours?-
AnotherKiwiGuy over 7 yearsHave you thought about cron? Something like
0 */4 * * * sudo reboot
? -
G. Macasero over 7 yearsIm just new with ubuntu. but i know about crontab
-
John N over 7 yearsWhy do you need your server rebooted? As ThatGuy mentioned, cron may be a good place to start. But in general Unix and Unix-like machines should be capable of running for days (or even weeks or months!) without needing restarted. It sounds like there may be another issue that needs addressing.
-
G. Macasero over 7 yearsBecause i'm runnning 8 minecraft servers in my dedicated server.
-
AnotherKiwiGuy over 7 years@JohnN has a point. Even with Minecraft servers, they should not require that the server be rebooted that frequently, unless you've misconfigured the game servers, or use mods with severe memory leaks.
-
-
Giridhur over 7 yearsBut would it automatically log in to the user account?
-
AnotherKiwiGuy over 7 yearsWhat user account? It would reboot the server using the root account, which should override every other user, regardless who is logged in.
-
Admin over 7 years@ThatGuy I think Giridhur is asking if after restart the log-in will be automatic.
-
AnotherKiwiGuy over 7 years@tomas - I see. If it is using Ubuntu Server, then definitely not. It would be a potential security problem, no administrator wants their server to auto login. If it's Ubuntu Desktop, then it depends on how he configured it.
-
Admin over 7 years@ThatGuy I think you should address your reply @ Giridhur.