I need help with my dedicated Ubuntu server.
How can I reboot my server every 4 hours?
Asked
Active
Viewed 1.4k times
3
Zanna
- 69,223
- 56
- 216
- 327
G. Macasero
- 31
- 1
- 1
- 2
-
1Have you thought about cron? Something like `0 */4 * * * sudo reboot`? – AnotherKiwiGuy Dec 07 '16 at 08:29
-
Im just new with ubuntu. but i know about crontab – G. Macasero Dec 07 '16 at 08:30
-
2Why 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. – John N Dec 07 '16 at 08:35
-
Because i'm runnning 8 minecraft servers in my dedicated server. – G. Macasero Dec 07 '16 at 08:38
-
@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. – AnotherKiwiGuy Dec 07 '16 at 08:39
1 Answers
3
The crontab Method
- Open your Terminal or SSH into your server
- Type
sudo crontab -eand 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.
AnotherKiwiGuy
- 4,350
- 1
- 20
- 38
-
-
What user account? It would reboot the server using the root account, which should override every other user, regardless who is logged in. – AnotherKiwiGuy Dec 07 '16 at 08:55
-
@ThatGuy I think Giridhur is asking if after restart the log-in will be automatic. – Dec 07 '16 at 14:02
-
@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. – AnotherKiwiGuy Dec 07 '16 at 22:14
-