bitlvl
EN

Cron ⇄ systemd timer converter

Paste a full crontab line, schedule and command, and get the two unit files plus the install commands. Or paste an OnCalendar line to get the cron equivalent.

Timer unit

 

Service unit

 

Install

 

Reverse: OnCalendar → cron

Cron versus systemd timers

cronsystemd timer
DefinitionOne line in a crontabTwo files: .timer (when) and .service (what)
Missed runsLost (unless anacron)Persistent=true runs them at next boot
EnvironmentMinimal PATH, no profile; output mailedDefined in the unit; output to the journal
OverlapRuns again even if the last run is still goingNever overlaps: a timer waits for its service to finish
DependenciesNoneAfter=network-online.target, mounts, other units
Resource limits, sandboxingNoAll of systemd's: MemoryMax, CPUQuota, ProtectSystem…
Inspectioncrontab -l, grep the syslogsystemctl list-timers, journalctl -u, systemctl status
SimplicityOne lineTwenty lines

For a one-liner on a personal machine, cron is fine. For anything on a server that must not overlap, must catch up after downtime, needs limits, or whose logs someone will read later, a timer is the better tool, and the converter writes the boilerplate.

What the converter does with the command

ExecStart= takes an absolute path and arguments, not a shell line. Redirections (>> log 2>&1) are dropped because the journal captures output; pipes and && are wrapped in /bin/sh -c '…'. Cron's %-means-newline rule does not apply, so date +%F works as written. Environment variables set in the crontab go into Environment= lines.

Day-of-month and day-of-week

If a cron line restricts both, cron fires when either matches; systemd requires both. The converter warns, since that schedule needs two timers to reproduce.

Questions

Where do the files go?

/etc/systemd/system/ for system units, ~/.config/systemd/user/ for user units (then use systemctl --user and loginctl enable-linger). Run systemctl daemon-reload after adding or editing.

How do I see when it will next run?

systemctl list-timers --all shows the next and last run of every timer. systemd-analyze calendar "expr" shows the next elapse for any OnCalendar expression.

How do I run it now, without waiting?

systemctl start name.service (not the timer). The timer keeps its own schedule.

Can a timer run every 10 seconds?

Yes, with OnCalendar=*:*:0/10 and AccuracySec=1s, or with OnUnitActiveSec=10s for “10 seconds after the last run finished”. Cron cannot go below one minute.