Skip to main content
Guide 5 min read

Cron vs systemd Timers: Which Should You Use?

You need a script to run every night. Maybe it backs up a database, clears a cache or pings an API. Two tools can schedule it on Linux, and the cron vs systemd timers debate has fans on both sides. Cron has run jobs for decades. Systemd timers arrived later and promise more control. So which one should you use?

Short answer: it depends on what the job needs. Longer answer: this guide compares them on the points that matter, shows where each one wins and gives you a simple rule for choosing. Then it walks you through turning an old cron job into a timer.

How cron works in thirty seconds

Cron is a small daemon that wakes up every minute and checks a list of jobs. Each job lives on one line in a crontab file. The line holds five time fields (minute, hour, day of month, month and day of week), followed by the command. Cron also understands shortcuts like @daily, @hourly and @reboot.

Setup takes one minute. You open your crontab, add a line and save. Our cron generator builds the five fields for you and shows the next upcoming run times.

That simplicity is why cron is everywhere. It’s also why it has gaps, and we’ll get to them.

How systemd timers work

A systemd timer uses two files. The service unit describes what to run. The timer unit describes when. By default a timer named backup.timer starts the service named backup.service.

Timers come in two flavors. Realtime timers use OnCalendar and follow the clock, like cron does. Monotonic timers use settings such as OnBootSec or OnUnitActiveSec and count time from an event, such as boot or the last run. That second kind has no cron equivalent. It’s how you run something every 30 seconds, or ten minutes after the machine starts.

Yes, two files take longer to write than one cron line. Here’s what you get for the extra effort.

Missed runs: what happens when the machine is off

Say your job runs at 3 AM and the server is down for maintenance. Cron simply skips that run, and nobody tells you. Some distros add anacron to catch up on daily and weekly jobs, but a plain cron line gets no such help.

A timer with Persistent=true remembers when it last fired. When the machine comes back, systemd runs the missed job right away. For laptops, home servers and any box that reboots, this feature alone can settle the debate.

Logging: where did the output go?

Cron sends a job’s output to the local mail system. If no mail system exists, the output often vanishes, which is a rough way to learn that your script failed last Tuesday. You can redirect output to a file, but you have to remember to do it.

Systemd captures everything the service prints and stores it in the journal, with timestamps and exit codes. You can read the log of one service, or check the status of the timer and the service to see the last result at a glance. If your job prints JSON, our JSON formatter makes it readable, and our regex tester helps you build a filter for the lines you care about.

Environment, limits and security

Cron runs your command with a thin environment. The shell is basic, the PATH is short and your profile never loads. That’s why a script works in your terminal and fails in cron. The cure is to use full paths and set variables at the top of the crontab.

Systemd also starts with a clean environment, but it gives you real controls in the unit file. Set the account with User=, cap memory with MemoryMax=, limit CPU with CPUQuota= and lock down the filesystem with settings like ProtectSystem= and PrivateTmp=. Cron has none of this. For a job that handles sensitive data or could run wild, that’s a big deal.

Overlapping runs and dependencies

What if last night’s backup still runs when tonight’s starts? Cron launches a second copy anyway. People work around it with a lock command, but they have to remember to add it.

Systemd won’t start a second copy of a service that’s still running, so overlaps stop on their own. Units can also declare order, such as waiting for the network or a mounted disk, with After= and Requires=. Cron fires at the clock time and hopes for the best.

Time zones and daylight saving

Both tools follow the system clock, and both stumble when the clocks change. A job set for 2:30 AM can skip a day or run twice when daylight saving shifts the hour. The cleanest fix is to run your server in UTC. Systemd also lets you add a time zone to the calendar expression. When you compare logs across servers, our timestamp converter turns Unix timestamps into readable dates.

Where cron still wins

Don’t write cron off. It wins in several places.

  • Portability. Cron runs on nearly every Unix like system, including BSD, Alpine and older Linux. Systemd runs only on Linux, and macOS leans on launchd.
  • Simplicity. One line, one file, done in a minute. For a throwaway job, two unit files is overkill.
  • Containers. Most containers don’t run systemd. Inside them, cron or your orchestrator’s scheduler (like Kubernetes CronJobs) is the usual route.
  • Familiarity. Your team already knows it, and a thousand tutorials cover every quirk.

So which should you use?

Here’s the rule I’d use. Pick systemd timers when a job must not be missed, needs logs, depends on other services or needs limits. Pick cron when you want the quickest setup, you need to run on many different systems or you’re inside a container.

Lots of teams use both. Cron handles the small chores, and timers handle the jobs that matter.

How to turn a cron job into a timer

Say you have this cron line: @daily /usr/local/bin/backup.sh. Here’s the timer version:

  1. Create /etc/systemd/system/backup.service with a Service section that sets Type=oneshot and ExecStart=/usr/local/bin/backup.sh.
  2. Create /etc/systemd/system/backup.timer with a Timer section that sets OnCalendar=daily and Persistent=true, plus an Install section with WantedBy=timers.target.
  3. Tell systemd to reload its unit files.
  4. Enable and start the timer, not the service.
  5. Start the service by hand once to test it, then read its log.
  6. Check the timer list for the next run time.
  7. Remove the old cron line once the timer works.

Want to catch typos? Paste your old and new files into our text diff checker. And if the job calls an API, rebuild the request in our API request builder before you schedule it.

Mistakes that bite both tools

A few slips cause most of the trouble.

  • Relative paths. Use full paths to every command and file.
  • Forgetting that systemd timers can fire up to a minute late by default. The AccuracySec setting controls it, so lower it if timing matters.
  • Enabling the service instead of the timer. The timer needs the enable step.
  • Using a percent sign in a crontab line without a backslash. Cron treats it as a line break.
  • Skipping a test run. Run the job by hand before you trust the schedule.
  • Ignoring user timers. A timer under a user account stops when that user logs out unless lingering is on.

Test your expression in our cron generator before adding it to production.

The short version

Cron is simple, portable and everywhere. Systemd timers add catch up runs, journal logs, dependencies and resource limits. Choose timers for jobs that matter on modern Linux servers, and cron for quick chores and portable setups. Many teams use both.

Pick one job on your server tonight and ask: would I notice if it missed a run? If yes, give it a timer.

Free browser based tools on Black Claaw to build schedules, format output, test patterns and compare configs.

View all tools

Advertisement