Cron to systemd

Convert a 5-field cron expression into a systemd timer plus a Kubernetes CronJob YAML file.

Reviewed by Olgun Ozoktas

Conversion runs in the browser. Analytics and ads may load on the page.

5 fields: minute hour day-of-month month day-of-week. Example: */5 * * * * or 0 9 * * 1-5.

OnCalendar: *-*-* *:00/5:00

systemd units

# converted.timer
[Unit]
Description=Timer converted from cron */5 * * * *
Requires=converted.service

[Timer]
OnCalendar=*-*-* *:00/5:00
AccuracySec=1s
Persistent=true
Unit=converted.service

[Install]
WantedBy=timers.target

# converted.service
[Unit]
Description=Service started by converted.timer

[Service]
Type=oneshot
ExecStart=/usr/local/bin/your-command

Kubernetes CronJob

apiVersion: batch/v1
kind: CronJob
metadata:
  name: converted
spec:
  schedule: "*/5 * * * *"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
            - name: converted
              image: busybox:1.36
              command:
                - /bin/sh
                - -c
                - "/usr/local/bin/your-command"

How to convert cron

  1. 1

    Paste a 5-field expression

    Example: */5 * * * * or 0 9 * * 1-5.
  2. 2

    Set a unit name and command

    These become the timer/service names and the CronJob command.
  3. 3

    Copy systemd units

    Copy the timer plus service pair.
  4. 4

    Copy CronJob YAML

    Review image and command before apply.

Why convert cron

systemd timers use OnCalendar, not crontab syntax. Kubernetes CronJob uses the 5-field cron string. This page emits both from one expression. Review ExecStart and the container command before you install the units. Conversion stays in your browser. Analytics or ads on the page may still load.

Frequently Asked Questions

1

Is this 5-field cron?

Yes. */5 * * * * becomes OnCalendar *-*-* *:00/5:00 and a CronJob schedule of that same string.
2

Does it run the job?

No. It emits unit files and YAML.
3

What about 0 9 * * 1-5?

OnCalendar is Mon..Fri *-*-* 09:00:00. The CronJob uses schedule "0 9 * * 1-5".
4

Can I use Quartz 6-field cron?

No. This converter is 5-field only.
5

Is the YAML valid?

It is a starting CronJob. Review image, name, and schedule before apply.

Rate This Tool

0/1000

Get Weekly Tools

Suggest a Tool