*/5 the same syntax as a systemd timer?
Search for is */5 the same syntax as a systemd timer and the answer is no.
*/5 * * * * That is a five-field crontab line: minute hour day-of-month month day-of-week. It means every five minutes on the clock—0, 5, 10, through 55. systemd timers speak OnCalendar, a different language. Pasting the crontab string into a timer unit is a common deploy mistake: the characters look familiar, the file accepts something that “looks scheduled,” and the next elapses are wrong or the unit fails validation for boring reasons.
Guide: https://kepttools.com/guides/cron-every-5-minutes
Why the mix-up happens
Both systems answer the same product question—“run this every five minutes”—so teams reuse the first syntax they remember. Crontab is older muscle memory on many hosts. systemd timers show up later in the same repo as .timer units next to .service files. Someone pastes */5 * * * * into OnCalendar= (or into a comment that somehow becomes config), assumes the daemon will interpret five cron fields, and ships.
It will not. OnCalendar is calendar expressions with their own grammar (*-*-* *:0/5:00-style shapes, weekday names, and more—exact forms depend on what you need). Stars and slashes appear in both worlds; that does not make them a shared dialect.
What five-field cron is doing
A standard crontab line has five time fields, then the command. Nothing in those five fields is a seconds field. */5 in the minute field steps 0–59 by five. The schedule is locked to the wall clock, not to when you saved the crontab. Minute 0 is included. Classic cron will not wait for a long job to finish before the next tick—overlap is a separate problem (flock, systemd Type=, etc.).
Build or check the string here before you copy it:
The generator does not install the job. Copy the expression—not the English sentence beside it. It also does not emit a .timer unit.
Worked contrast
| System | Language | What to do with */5 * * * * |
|---|---|---|
| crontab (Vixie/cronie) | five fields | Valid every-five-minutes schedule |
| systemd timer | OnCalendar= | Do not paste that string; write OnCalendar and verify |
On the host that will run the timer, check the expression you actually want:
systemd-analyze calendar 'your-oncalendar-expression' Read the next elapses. Use the calendar syntax your unit needs—not a crontab line that “looks close enough.” Enable the timer only after that check looks right on that machine (timezone and systemd version matter more than a screenshot from another box).
Related crontab facts (same guide)
- Locked to the wall clock, not to save time—save at 10:03 and the next
*/5tick is 10:05, not “five minutes later.” - Minute 0 is in the set;
5-59/5is the common way people accidentally skip:00. - Classic cron starts again on the next clock match even if the previous process is still running.
- Quartz and EventBridge use six-field shapes (and often
?). A five-field KeptTools line matches neither.
Those are crontab problems. Mixing them with OnCalendar just stacks two confusion sources.
Checklist before you ship a timer
- Name the scheduler in the PR: crontab or systemd timer—not “cron-ish.”
- If crontab: five fields only; verify with your host’s crontab docs / a dry log line.
- If systemd: write
OnCalendar=, pair with the.service, runsystemd-analyze calendaron the target host. - Do not translate by pasting five fields into the calendar line and hoping.
- Keep browser generators in their lane: five-field help is not a unit writer.
Honest limit
Limit: the cron generator builds five-field crontab only; it does not write systemd units, does not install jobs, and cannot validate OnCalendar for you.
Closing
Need every five minutes in crontab? */5 * * * * is the line. Need a systemd timer? Stay in OnCalendar and verify with systemd-analyze calendar on that machine. Same interval intent, different config file—name the scheduler first, then pick the syntax.
Full walkthrough: https://kepttools.com/guides/cron-every-5-minutes
原文:https://www.a8q9.cn/en/article/5-the-same-syntax-as-a-systemd-timer-962cce.html