Run a job every minute
The cron expression for every minute is * * * * *. A * in all five fields matches every minute of every hour and day, 1,440 runs a day. That is as often as cron goes: it has no seconds field.
*****Next 5 runs
Vercel always runs schedules in UTC, and GitHub Actions does unless you set a time zone. Crontab and Kubernetes use the server's time zone.
Field by field
*Minute- Every minute
*Hour- Every hour, 0 to 23
*Day of month- Every day of the month
*Month- Every month
*Day of week- Every day of the week
By platform
Most schedulers take the same five fields. The wrapper, time zone and limits differ.
# m h dom mon dow command
* * * * * /usr/local/bin/sync.sh >> /var/log/sync.log 2>&1Runs in the server's local time zone
on:
schedule:
- cron: "* * * * *"GitHub runs schedules at most every 5 minutes
spec:
schedule: "* * * * *"
timeZone: "Etc/UTC"
concurrencyPolicy: ForbidWithout timeZone, the controller's zone applies
aws events put-rule \
--name sync-every-minute \
--schedule-expression "cron(* * * * ? *)"Six fields, and one day field must be ?
? in day-of-month or day-of-week. For a plain interval, rate(1 minute) is simpler, though its runs are timed from when you create the rule rather than by the clock.{
"crons": [
{ "path": "/api/sync", "schedule": "* * * * *" }
]
}Needs a paid plan
Other every-minute schedules
Keep the minute as * and narrow the hour or weekday fields to run every minute only part of the time.
| Expression | Runs |
|---|---|
*/1 * * * * | Same as * * * * *, written as a step of 1 |
* 9-17 * * 1-5 | Every minute from 09:00 through 17:59, Monday through Friday |
* 0 * * * | Every minute from 00:00 through 00:59, then not until tomorrow |
*/2 * * * * | Every 2 minutes, 720 runs a day |
Run a cron job every 30 seconds
No cron expression runs more often than once a minute, because cron checks its table once a minute. To run a job every 30 seconds, add it twice: one line runs at the start of each minute, the other waits 30 seconds first.
# Every 30 seconds: at :00 and :30 of every minute
* * * * * /usr/local/bin/job.sh
* * * * * sleep 30; /usr/local/bin/job.shFor every 20 seconds use three lines (no sleep, sleep 20, sleep 40); for every 15 seconds, four. If a run can take longer than the gap, start the command with flock -n /tmp/job.lock so a new run is skipped while the last one is still going.
Schedulers that have a seconds field can do it in one line:
| Scheduler | Every 30 seconds |
|---|---|
| systemd timer | OnCalendar=*:*:0/30 with AccuracySec=1s; the default accuracy of one minute would blur the runs together |
| Quartz | */30 * * * * ? |
| Spring @Scheduled | */30 * * * * * |
Kubernetes CronJobs and AWS EventBridge stop at one minute, and GitHub Actions at five.
Test that cron works with an every-minute job
Because * * * * * fires at the start of every minute, it is the quickest way to check that cron runs jobs at all before you trust it with a real schedule.
Open your crontab with crontab -e, add this line, save, and wait a minute or two. The change applies without restarting cron; the first run comes at the start of the next minute or the one after.
# Temporary: prove that cron runs your jobs, then delete this line
* * * * * date >> /tmp/cron-test.log 2>&1Then check the file and cron's log:
tail -f /tmp/cron-test.log # a new line each minute
journalctl -u cron --since "5 min ago" # Debian and Ubuntu: look for CMD lines
journalctl -u crond --since "5 min ago" # Fedora and RHELA new line in the file every minute means cron and your crontab work, so if your real job still fails the cause is the command: its PATH, working directory or permissions. No line and no CMD entry in the log means cron never started it; work through cron job not running and check that the cron service is running.
When you're done, delete the line in crontab -e. Don't use crontab -r: it removes the whole crontab, not one job.
An every-minute job is 1,440 runs a day
MAILTO="" and send output to a file you rotate:MAILTO=""
* * * * * /usr/local/bin/job.sh >> /var/log/job.log 2>&1