coiai Logo

This article is an English translation of the original Japanese post. Read the Japanese original →

Ubuntu: Using crontab to Reboot at a Fixed Time Every Day

February 6, 2025

Categories: Linux · Tags: Ubuntu, サーバー

Ubuntu: Using crontab to Reboot at a Fixed Time Every Day

When running Ubuntu as a home server, it's a good idea to reboot it periodically.

When a system or service stays running for a long time, it can occasionally hang or run into glitches. Rebooting on a regular schedule helps prevent these problems before they happen and keeps operation stable.

Environment

As of 2025/02/06

How to do it

We'll use the crontab command, which is used to automatically run commands or scripts on a schedule.

Open the cron job editing screen.

sudo crontab -e

You'll be asked to choose an editor, so select nano.

crontab

Add the schedule. Here I set it to reboot every day at 3:00 AM.

0 3 * * * /sbin/shutdown -r now

Syntax

crontab edit

Once you've entered it, save with Ctrl+O, then exit with Return and Ctrl+X.

Verify

You can check with the following command.

sudo systemctl status cron

The logs are recorded here.

grep CRON /var/log/syslog

Ubuntu: Using crontab to Reboot at a Fixed Time Every Day | coiai Inc.