Skip to content

How to Schedule Nightly Reboots on Fedora CoreOS

Schedule a nightly 11 PM reboot on Fedora CoreOS with a systemd oneshot service and timer. No cron, and it catches up if the box was off.

On this page
  1. Should you even reboot every night?
  2. Prerequisites
  3. Step 1: Create a reboot service
  4. Step 2: Set up a timer
  5. Step 3: Activate the timer
  6. Step 4: Double-check it’s working
  7. A few extra tips
  8. Troubleshooting
  9. Timer never appears
  10. It reboots at the wrong hour
  11. It reboots on boot at 8 AM
  12. Quadlet containers do not return after the reboot
  13. I want a reboot only if an update is waiting
  14. Wrap-up

If you’re running a Fedora CoreOS server, you might want a nightly reboot to keep things fresh or apply updates. CoreOS is minimal and immutable, so we’ll use systemd timers instead of cron. Let’s set up a reboot every night at 11 PM.

I use this on homelab appliances. Pair it with Quadlets so services come back without SSH: Pi-hole Quadlet, AdGuard Quadlet, or the full CoreOS + Bitwarden + AdGuard Ignition guide.

Should you even reboot every night?

Good reasons: a predictable reboot after zincati / automatic updates, old hardware that gets flaky after days of uptime, or DNS down for 90 seconds at 23:00 instead of at a random time.

Bad reasons: reboots alone don’t make it more secure. Patching does. CoreOS already reboots when Zincati applies an update, depending on your config, so you may only want this timer on machines that rarely update or have automatic reboots disabled.

DNS / DHCP appliances: DNS is down for every client until Podman is back. 03:30 is kinder than 23:00. I use 23:00 below. Change OnCalendar for another time.

Prerequisites

  • Fedora CoreOS with sudo (core user).
  • Correct clock and timezone (timedatectl). Timers fire in local time unless you use UTC in the calendar spec.
  • Services that start on boot (Quadlets, WantedBy=multi-user.target, etc.).
  • Physical or IPMI/console access the first night, in case the box doesn’t come back.

Check the time first:

Terminal window
timedatectl
date
systemctl list-timers --all | head

If it says NTP synchronized: no, fix that (sudo timedatectl set-ntp true or whatever your network allows).

Step 1: Create a reboot service

First, create a systemd service in /etc/systemd/system/ to do the reboot. Call it reboot-nightly.service:

Terminal window
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). A oneshot service is perfect for a one-and-done action like rebooting.

Why not ExecStart on the timer? Timers activate services. Keeping reboot in its own service lets you test it with systemctl start reboot-nightly.service and add ExecStartPre= later (say, to skip during a backup) without touching the timer. shutdown -r now works as well as /usr/sbin/reboot. Avoid systemctl isolate in a oneshot.

There’s no [Install] on the service. We enable the timer.

Step 2: Set up a timer

Now create reboot-nightly.timer in the same directory:

Terminal window
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 catches up on a missed reboot if the system was off at 11 PM.
  • The Unit line ties this timer to our service.

About Persistent=true: if the box was off at 23:00, it may reboot shortly after it boots. Not great if you power it on at 08:00 for a demo. For a laptop you only sometimes leave on, consider Persistent=false.

Other schedules:

# 03:30 local, every day
OnCalendar=*-*-* 03:30:00
# 23:00 on weekdays only
OnCalendar=Mon..Fri 23:00:00
# 11 PM UTC regardless of timezone
OnCalendar=*-*-* 23:00:00 UTC

See man systemd.time. Test a calendar string without rebooting:

Terminal window
systemd-analyze calendar '*-*-* 23:00:00'

It prints the next run time. If that’s wrong, your timezone is wrong, not the timer file.

Step 3: Activate the timer

Run these commands:

Terminal window
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 (starts the timer, not an immediate reboot).

You shouldn’t see errors. enable may print Created symlink 
 reboot-nightly.timer. If daemon-reload reports a parse error, check the file with systemctl cat reboot-nightly.timer.

To test the reboot without waiting until night (only when you’re ready):

Terminal window
# optional live test — this WILL reboot now
# sudo systemctl start reboot-nightly.service

It’s commented out on purpose. Run it once from the console.

Step 4: Double-check it’s working

Let’s confirm the timer is set:

Terminal window
systemctl list-timers
systemctl status reboot-nightly.timer
systemctl list-timers reboot-nightly.timer

You’ll see reboot-nightly.timer in the list, with its next run time. If it’s there, you’re golden.

The list-timers columns are NEXT, LEFT, LAST, PASSED, UNIT, ACTIVATES. NEXT should be tonight (or tomorrow if it’s past 23:00). LAST may be - until it first fires.

A few extra tips

  • Time zone check: The timer uses local time. Check with timedatectl and change it with sudo timedatectl set-timezone YOUR_TIMEZONE, for example sudo timedatectl set-timezone America/Denver.
  • Root access: You’ll need sudo since we’re modifying system files.
  • CoreOS quirk: These files live in /etc, which survives OSTree updates, so you don’t recreate them after Zincati. Don’t mess with /usr. It’s read-only by design.
  • Zincati: if automatic updates also reboot, you can get two reboots in one night. Check sudo systemctl status zincati and the FCOS auto-updates docs, and line up the two schedules.
  • Laptop appliances: for lid-ignore on CoreOS laptops, the beginner CoreOS post has the HandleLidSwitch=ignore drop-in.
  • Disable later: sudo systemctl disable --now reboot-nightly.timer. You can leave the files or rm them.

Troubleshooting

Timer never appears

Wrong path (/usr/lib vs /etc), or you forgot daemon-reload. Names must be something.timer and something.service, matching Unit=.

It reboots at the wrong hour

Timezone. Compare timedatectl to your wall clock, and check you didn’t add UTC on the calendar line.

It reboots on boot at 8 AM

That’s Persistent=true catching up. Set it to false or pick a time the machine is always on.

Quadlet containers do not return after the reboot

Not the timer’s fault. Fix [Install] WantedBy=multi-user.target in the .container file and test sudo reboot during the day. See the Pi-hole Quadlet post.

I want a reboot only if an update is waiting

That’s Zincati’s job. Configure its update strategy instead of scripting around rpm-ostree status.

Wrap-up

And that’s it! Your Fedora CoreOS server will now reboot every night at 11 PM like clockwork. To change the timing, just adjust the OnCalendar line. Happy automating.

Best regards,

The Linux IT Guy