A five-segment schedule ring splits into a pair of systemd unit cards and a Kubernetes CronJob document silhouette.
Developer5 min read@codewitholgun

Cron to systemd: Convert Crontab to Timers and CronJobs

Tags:Developer ToolsCronsystemdKubernetesTimers

A cron-to-systemd converter turns a 5-field crontab line into a systemd timer plus service unit, and into Kubernetes CronJob YAML. Paste the expression into the FindUtils Cron to systemd tool, set a unit name and command, then copy the files. Conversion runs in your browser. The tool does not run the job.

Six-field cron (with seconds) is rejected. Review ExecStart and the container command before you install anything.

Why Convert Cron

systemd timers use OnCalendar, not crontab syntax. Kubernetes CronJob keeps the 5-field cron string. One converter that emits both saves a manual rewrite.

Convert cron when:

  • You are moving a crontab onto a host that uses systemd. You need a .timer and a .service.
  • You are moving a schedule into a cluster. You need a CronJob object.
  • You want to see OnCalendar next to the original line. The mapping is easy to get wrong by hand.
  • Both day-of-month and day-of-week are set. cron treats that as OR. systemd OnCalendar treats it as AND. The page warns on that case.

The honest limit: the YAML is a starting CronJob. Review image, name, and schedule before kubectl apply.

How to Convert a Cron Expression

Use 5 fields: minute, hour, day-of-month, month, day-of-week.

Step 1: Paste a 5-field expression

Open the FindUtils Cron to systemd tool. Examples: */5 * * * * or 0 9 * * 1-5. Presets cover every 5 minutes, weekdays at 09:00, hourly, and daily midnight.

Step 2: Set a unit name and command

The unit name becomes the timer, service, and CronJob name. The command becomes ExecStart and the container command. Default command is /usr/local/bin/your-command if you leave it blank.

Step 3: Copy systemd units

Copy the timer plus service pair. Install them on a host that uses systemd. Enable the timer after you review the command.

Step 4: Copy CronJob YAML

Copy the YAML. Set a real image. Apply only after you read the schedule.

If you still need to build a cron line, use the Cron Expression Generator first, then convert it.

Cron vs systemd OnCalendar vs Kubernetes CronJob

The same English schedule is not the same syntax in each system.

AspectCrontab (5-field)systemd timerKubernetes CronJob
Schedule fieldm h dom mon dowOnCalendar=schedule: 5-field cron
SecondsNot in 5-field formYes, in OnCalendarNot in standard CronJob
DOM + DOW both setORANDcron OR semantics
This converterInputEmits .timer + .serviceEmits YAML
Runs the jobcron daemonsystemdkube-controller

Worked mappings from this converter:

  • */5 * * * * becomes OnCalendar *-*-* *:00/5:00 and a CronJob schedule of that same cron string.
  • 0 9 * * 1-5 becomes OnCalendar Mon..Fri *-*-* 09:00:00 and CronJob 0 9 * * 1-5.

Practical Examples

Example 1: Every 5 minutes on a VM

Paste */5 * * * *. Set unit name backup and command /usr/local/bin/backup.sh. Copy the units. Enable the timer on the host.

Example 2: Weekday morning report in a cluster

Paste 0 9 * * 1-5. Copy CronJob YAML. Replace the image and command. Apply in the target namespace.

Example 3: Catch the DOM + DOW warning

Paste 0 0 1 * 1. Both day-of-month and day-of-week are set. cron fires on the 1st or on Monday. systemd OnCalendar needs both. Read the warning before you ship the timer.

Common Mistakes

Mistake 1: Pasting Quartz 6-field cron

A leading seconds field is rejected. Use 5 fields only.

Mistake 2: Installing units without reading ExecStart

The command you type is copied into the service. A placeholder path will fail at runtime.

Mistake 3: Assuming DOM + DOW match cron on systemd

That combination is OR in cron and AND in OnCalendar. Check the warning.

Mistake 4: Applying YAML with the sample image still in place

The YAML is a starting point. Set image, name, and schedule first.

Limits You Should Plan For

The converter accepts the 5-field form only. A sixth seconds field is an error, not a silent drop.

OnCalendar is a best-effort mapping of the fields you typed. Review the timer after you copy it, especially when the expression uses lists, ranges, or both day fields.

Kubernetes CronJob YAML from this page is a starting object. It does not set resource limits, a real container image, or a namespace. Fill those in before apply.

Conversion does not talk to systemd or to a cluster. Nothing is installed until you copy the files to a host you control.

Tools Used in This Guide

FAQ

Q1: Is cron to systemd free? A: Yes. FindUtils Cron to systemd is free, with no signup. Conversion runs in your browser.

Q2: Is this 5-field cron? A: Yes. Six-field expressions with seconds are rejected.

Q3: Does it run the job? A: No. It emits unit files and YAML.

Q4: Can I use Quartz 6-field cron? A: No. This converter is 5-field only.

Q5: Is the YAML valid? A: It is a starting CronJob. Review image, name, and schedule before apply.

Q6: What about 0 9 * * 1-5? A: OnCalendar is Mon..Fri *-*-* 09:00:00. The CronJob uses schedule 0 9 * * 1-5.

Q7: Do I need an account? A: No. Paste the expression and copy the files.

Next Steps

Share this as an X post