How to run a cron job every 30 seconds
Common use cases
This is one of the most frequently searched cron queries — and the answer is that standard cron can't do it. Cron's minimum granularity is one minute. But the need for sub-minute scheduling is real.
The bash sleep trick is the simplest: add two entries to your crontab, one running normally and one with "sleep 30 &&" prefixed. The first runs at :00, the second waits 30 seconds then runs.
systemd timers are the proper Linux solution. Create a .timer unit with OnUnitActiveSec=30s and a matching .service unit for genuine second-level precision.
Language-level schedulers like Python's APScheduler, Node.js's node-cron (which supports a seconds field), or Go's robfig/cron library all support sub-minute intervals.
Platform-specific syntax
crontab
# Not directly supported. Use two entries:
* * * * * /path/to/script.sh
* * * * * sleep 30 && /path/to/script.shAWS EventBridge
# EventBridge minimum: rate(1 minute)
# Use Step Functions with a Wait state for sub-minuteGitHub Actions
# GitHub Actions minimum: 5 minutes
# Not suitable for sub-minute schedulingKubernetes
# CronJob minimum: 1 minute
# Use a Deployment with a sleep loop insteadFrequently asked questions
Is the 'sleep 30' trick reliable?
For most purposes, yes. The two crontab entries fire at :00 each minute; the second one sleeps for 30 seconds before executing. The timing won't be perfectly precise, but for the vast majority of use cases it's accurate enough.