Short answer

Make two files in /etc/systemd/system/: myjob.service (Type=oneshot, ExecStart= your script) and myjob.timer (OnCalendar=*-*-* 03:00:00, Persistent=true, WantedBy=timers.target). Check the schedule with systemd-analyze calendar, then run sudo systemctl enable --now myjob.timer. Enable the timer, not the service.

Tested on Ubuntu 26.04 and 24.04, two separate runs. On 24.04, every step is the same. Everything that differed

Step 1: The job, as a service

The example job deletes files in /var/tmp older than 7 days and says how many:

Server
$ sudo tee /usr/local/bin/cleanup-tmp > /dev/null <<'EOF'#!/bin/shn=$(find /var/tmp -name '*.tmp' -mtime +7 -print -delete | wc -l)echo "cleanup: removed $n old files"EOF
Server
$ sudo chmod +x /usr/local/bin/cleanup-tmp

A timer starts a service, so the job needs a service file. Type=oneshot means it runs, finishes, and is done; it has no [Install] section because the timer, not the boot, starts it:

Server
$ sudo tee /etc/systemd/system/cleanup.service <<'EOF'[Unit]Description=Remove old temp files [Service]Type=oneshotExecStart=/usr/local/bin/cleanup-tmpEOF

Run it once by hand before scheduling it, and read what it printed:

Server
$ sudo systemctl daemon-reload && sudo systemctl start cleanup.service
Server
$ sudo journalctl -u cleanup -o cat --no-pagerStarting cleanup.service - Remove old temp files...cleanup: removed 3 old filescleanup.service: Deactivated successfully.Finished cleanup.service - Remove old temp files.
Output hidden (4 lines)

The test server had three old files and one new one; the job removed the three.

Step 2: The timer

Same name as the service, ending in .timer, so it starts cleanup.service:

Server
$ sudo tee /etc/systemd/system/cleanup.timer <<'EOF'[Unit]Description=Remove old temp files every night [Timer]OnCalendar=*-*-* 03:00:00Persistent=true [Install]WantedBy=timers.targetEOF
  • OnCalendar=*-*-* 03:00:00: every day at 03:00 (year-month-day hour:minute:second; * is any). The cron line 0 3 * * *.
  • Persistent=true: if the server was off at 03:00, run once when it is back (proved below).
  • WantedBy=timers.target: what enable hooks the timer to, so it is armed at every boot.

Check an expression before you trust it. systemd-analyze calendar shows how systemd reads it and when it would run next:

Server
$ systemd-analyze calendar "*-*-* 03:00:00"Normalized form: *-*-* 03:00:00    Next elapse: Fri 2026-11-20 03:00:00 UTC       From now: 4h 6min left
Output hidden (3 lines)

Which time zone does OnCalendar use?

The server’s own time zone. A cloud server usually runs on UTC:

Server
$ timedatectl | grep "Time zone"                Time zone: Etc/UTC (UTC, +0000)
Output hidden (1 line)

So 03:00 means 03:00 UTC. To schedule in another zone without changing the server’s, add it after the time:

Server
$ systemd-analyze calendar "*-*-* 03:00:00 Europe/Berlin"Normalized form: *-*-* 03:00:00 Europe/Berlin    Next elapse: Fri 2026-11-20 02:00:00 UTC       From now: 3h 6min left
Output hidden (3 lines)

03:00 in Berlin is 02:00 UTC in November, and systemd works that out itself.

If you enable the service: “The unit files have no installation config”

Server
$ sudo systemctl enable cleanup.serviceThe unit files have no installation config (WantedBy=, RequiredBy=, UpheldBy=,Also=, or Alias= settings in the [Install] section, and DefaultInstance= fortemplate units). This means they are not meant to be enabled or disabled using systemctl. Possible reasons for having these kinds of units are:• A unit may be statically enabled by being symlinked from another unit's  .wants/, .requires/, or .upholds/ directory.• A unit's purpose may be to act as a helper for some other unit which has  a requirement dependency on it.• A unit may be started when needed via activation (socket, path, timer,  D-Bus, udev, scripted systemctl call, ...).• In case of template units, the unit is meant to be enabled with some  instance name specified.
Output hidden (13 lines)

Nothing was enabled. The service has no [Install] section on purpose: the timer starts it (“activation … timer” in the list). This message is harmless; enable the timer instead.

Step 3: Enable the timer

Server
$ sudo systemctl enable --now cleanup.timerCreated symlink '/etc/systemd/system/timers.target.wants/cleanup.timer' → '/etc/systemd/system/cleanup.timer'.
Output hidden (1 line)
Server
$ systemctl list-timers cleanup.timer --no-pagerNEXT                           LEFT LAST PASSED UNIT          ACTIVATESFri 2026-11-20 03:00:00 UTC 4h 6min -         - cleanup.timer cleanup.service 1 timers listed.Pass --all to see loaded but inactive timers, too.
Output hidden (5 lines)

NEXT is the next run, LEFT the time until it, and - under LAST means it has not run yet. systemctl list-timers without a name lists every timer on the server.

Step 4: Check it after a reboot

Server
$ sudo reboot
Server
$ systemctl list-timers cleanup.timer --no-pagerNEXT                           LEFT LAST                        PASSED UNIT          ACTIVATESFri 2026-11-20 03:00:00 UTC 4h 6min Thu 2026-11-19 22:53:10 UTC      - cleanup.timer cleanup.service 1 timers listed.Pass --all to see loaded but inactive timers, too.
Output hidden (5 lines)

The timer is armed again for 03:00. LAST now shows a time, but the job did not run: with Persistent=true systemd keeps a stamp file in /var/lib/systemd/timers/, writes the current time into it when the timer first starts, and reads it back at boot. A separate test confirmed cleanup.service had no new journal lines after the reboot.

What Persistent=true does with missed runs

To see it in minutes rather than days, a second timer ran every minute, was stopped for two and a half minutes (two runs missed) and started again:

Server
$ sudo tee /etc/systemd/system/tick.service > /dev/null <<'EOF'[Service]Type=oneshotExecStart=/bin/echo tickEOF
Server
$ sudo tee /etc/systemd/system/tick.timer > /dev/null <<'EOF'[Timer]OnCalendar=minutelyPersistent=true [Install]WantedBy=timers.targetEOF
Server
$ sudo systemctl daemon-reload && sudo systemctl enable --now tick.timer
Server
$ sudo systemctl stop tick.timer
Server
$ sudo systemctl start tick.timer
Server
$ sudo journalctl -u tick -o short-iso --no-pager | grep tick$2026-11-19T22:54:02+00:00 web-server echo[2736]: tick2026-11-19T22:56:35+00:00 web-server echo[3470]: tick
Output hidden (2 lines)

One run before the stop, and ONE run the moment the timer was started again, not one for each missed minute. A server that was off for a week runs a daily job once when it comes back, not seven times. (The test removed the tick timer afterwards.)

Remove the timer

Server
$ sudo systemctl disable --now cleanup.timerRemoved '/etc/systemd/system/timers.target.wants/cleanup.timer'.
Output hidden (1 line)
Server
$ sudo rm /etc/systemd/system/cleanup.timer /etc/systemd/system/cleanup.service /usr/local/bin/cleanup-tmp && sudo systemctl daemon-reload
Server
$ systemctl list-timers --all --no-pager | grep -c cleanup0
Output hidden (1 line)

The configuration files, ready to copy

The two files as they were on the test server after the reboot, with the timer armed.

The job
/etc/systemd/system/cleanup.service
[Unit]Description=Remove old temp files [Service]Type=oneshotExecStart=/usr/local/bin/cleanup-tmp

Read back from the test server (Ubuntu 26.04) on 2026-11-19, after the steps had worked. Placeholders such as [password]: type your own value in the box above the file to fill them in, or replace them yourself.

The timer
/etc/systemd/system/cleanup.timer
[Unit]Description=Remove old temp files every night [Timer]OnCalendar=*-*-* 03:00:00Persistent=true [Install]WantedBy=timers.target

Read back from the test server (Ubuntu 26.04) on 2026-11-19, after the steps had worked. Placeholders such as [password]: type your own value in the box above the file to fill them in, or replace them yourself.

Troubleshooting

  • “The unit files have no installation config”: you enabled the .service; enable the .timer. Details.
  • It runs an hour early or late: OnCalendar uses the server’s time zone (often UTC). Add the zone after the time. Details.
  • The job never seems to run: check NEXT and LAST in systemctl list-timers, then journalctl -u the service. Details.
  • LAST shows a time but the job did not run: that is the stamp of a Persistent timer, not a run. Details.

What these steps changed on the server

Both runs recorded the server before the first step and after the reboot (see the Tested on box below): the service file, the timer file, and the timer’s link in timers.target.wants. Nothing was installed.

Ubuntu 26.04 vs 24.04

The same check ran on a fresh 26.04 server and on a fresh 24.04 server, each with its own run log. Every step behaved the same, including the single catch-up run; only one output differed in form:

WhatUbuntu 26.04Ubuntu 24.04
SystemUbuntu 26.04.1 LTS7.0.0-43-genericUbuntu 24.04.5 LTS6.8.0-147-generic
systemd259.9-0ubuntu0.1255.4-1ubuntu8.18
The “Created symlink” / “Removed” linespaths in single quotespaths without quotes (“Removed” with double quotes)
ProofRun log, 18 checks passedRun log, 18 checks passed