Cron every 30 seconds
One cron expression cannot say "every 30 seconds", but a short crontab workaround can. Below: the lines, how they work, what daylight saving does to them, and how to get an alert when the job stops.
*Minute*Hour*Day of month*Month*Day of weekEvery minute, every day.
* * * * * /usr/local/bin/job.sh
* * * * * sleep 30; /usr/local/bin/job.shHow do you run a job every 30 seconds with cron?
Cron counts in whole minutes. The first line runs at the start of every minute; the second waits 30 seconds and then runs the same job, so together they run it twice a minute.
* * * * * /usr/local/bin/job.sh
* * * * * sleep 30; /usr/local/bin/job.shWhat does * * * * * mean?
Every minute, every day.
| Field | Written | Means |
|---|---|---|
| Minute | * | every minute |
| Hour | * | every hour |
| Day of month | * | every day of month |
| Month | * | every month |
| Day of week | * | every day of week |
How often does it run?
On a day it runs, it runs 1,440 times. It runs on 365 days of 2027, 525,600 runs in all. Runs are 1 minute apart.
- Runs on a day it runs
- 1,440
- Days it runs in 2027
- 365
- Runs in 2027
- 525,600
- Shortest gap
- 1 minute
When is this schedule useful?
Near-real-time jobs such as draining a small queue, sending pending notifications, or polling a sensor, on a host where a long-running daemon is not an option.
What should you watch out for?
If one run takes longer than 30 seconds, runs overlap. Use flock -n, and consider a small service with a loop instead.
What happens when the clocks change?
On Sunday 14 March 2027, clocks in America/New_York jump from 02:00 to 03:00. The 60 runs from 02:00 to 02:59 fall in the missing hour and do not happen, because cronie schedules jobs that run more than once an hour normally.
On Sunday 1 November 2026, clocks in America/New_York fall back from 02:00 to 01:00, so the hour from 01:00 happens twice. Cronie runs this schedule normally through the repeated hour, so 11 runs happen twice, once at each offset.
A server that keeps its clock on UTC never sees either change. The next run calculator previews any zone.
How do you get an alert when it stops running?
Create a simple check that expects a ping every 1 minute, with 1 minute of grace, then ping it at the end of the job. If a run does not report in by the end of the grace time, CronMissed sends an alert.
* * * * * /usr/local/bin/job.sh && curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null "https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10"
* * * * * sleep 30; /usr/local/bin/job.sh && curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null "https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10"The snippet builder writes the same ping for systemd, GitHub Actions, Vercel, Kubernetes and backup scripts.
Questions and answers
- Every minute, every day. On its own it does not give this schedule; the crontab lines on this page add what one expression cannot.
- On a day it runs, it runs 1,440 times. It runs on 365 days of 2027, 525,600 runs in all. Runs are 1 minute apart.
- Create a simple check that expects a ping every 1 minute, with 1 minute of grace, then add the ping to the end of the job so it requests the check URL after each successful run. If a run does not report in by the end of the grace time, CronMissed alerts you by email, Slack, Discord, Telegram, ntfy or webhook.
What does * * * * * mean in cron?
How often does * * * * * run?
How do I get an alert when this job stops running?
Know the first time this schedule misses a run
CronMissed expects a ping at every run of * * * * *. When one is late or reports a failure, you get an alert by email, Slack, Discord, Telegram, ntfy or webhook.