If you’re running a Fedora CoreOS server, you might want to schedule a nightly reboot—maybe to keep things fresh or apply updates automatically. Since CoreOS is a minimal, immutable system, we’ll lean on systemd timers instead of the classic cron approach. Let’s set up a reboot every night at 11 PM. Here’s the step-by-step guide, with copy-paste-ready snippets!
Step 1: Create a Reboot Service
First, we need a systemd service to handle the reboot itself. Fedora CoreOS keeps things clean, so we’ll put this in /etc/systemd/system/. Let’s call it reboot-nightly.service.
Create the file with this command (you’ll need sudo):
sudo nano /etc/systemd/system/reboot-nightly.service
Paste this into the file:
[Unit]
Description=Nightly reboot at 11 PM
[Service]
Type=oneshot
ExecStart=/usr/sbin/reboot
Save and exit (Ctrl+O, Enter, Ctrl+X in nano). This is a simple oneshot service—perfect for a one-and-done action like rebooting.
Step 2: Set Up a Timer
Now, let’s schedule it with a systemd timer. Create a file called reboot-nightly.timer in the same directory:
sudo nano /etc/systemd/system/reboot-nightly.timer
Paste this:
[Unit]
Description=Run nightly reboot at 11 PM
[Timer]
OnCalendar=*-*-* 23:00:00
Persistent=true
Unit=reboot-nightly.service
[Install]
WantedBy=timers.target
Save and exit again. Here’s what’s happening:
-
OnCalendar=*-*-* 23:00:00 means “every day at 11 PM” (local time).
-
Persistent=true ensures the reboot triggers even if the system was off at 11 PM—it’ll catch up when it’s back online.
-
The Unit line ties this timer to our service.
Step 3: Activate the Timer
Time to make it official! Run these commands:
sudo systemctl daemon-reload
sudo systemctl enable reboot-nightly.timer
sudo systemctl start reboot-nightly.timer
-
daemon-reload refreshes systemd with our new files.
-
enable keeps the timer active across reboots.
-
start kicks it off right away.
Step 4: Double-Check It’s Working
Let’s confirm the timer is set:
systemctl list-timers
You’ll see reboot-nightly.timer in the list, with its next run time. If it’s there, you’re golden!
A Few Extra Tips
-
Time Zone Check: The timer uses your server’s local time. Run timedatectl to see it, and adjust with sudo timedatectl set-timezone YOUR_TIMEZONE if needed.
-
Root Access: You’ll need sudo for all this since we’re modifying system files.
-
CoreOS Quirk: These changes live in /etc, which survives updates. Don’t mess with /usr—it’s read-only by design.
And that’s it! Your Fedora CoreOS server will now reboot every night at 11 PM like clockwork. If you run into snags or want to tweak the timing, feel free to experiment—just adjust the OnCalendar line. Happy automating!