Running a cron job every 30 seconds

By: Shane Harter|Last Updated: Oct 09, 2026

In a standard Linux cron expression, you have 5 fields: minute, hour, day-of-month, month, and day-of-week. With these fields you can create endless combinations of cron schedules, but none will run more frequently than once a minute. This guide will show you a simple way to overcome this limitation and run your cron jobs every 30 seconds.

How to run a cron job every 30 seconds

To run a cron job every 30 seconds, schedule an every minute crontab entry, and use a bash script to run your job twice, with a 30-second sleep in between. Here's an example of that shell script:

#!/bin/bash
for (( i=1; i<=2; i++ )); do
    # Invoke your command here, the same as you would from your crontab
    # The & at the end will run the job in a background shell, so the 30 second sleep will start immediately
    python /home/crons/send-updates.py &
    sleep 30
done

In this scenario, we will save this script as /home/crons/send-updates-wrapper.sh, but wherever you save it, don't forget to make it executable by running chmod +x /home/crons/send-updates-wrapper.sh. This is what your crontab entry should look like:

* * * * * /home/crons/send-updates-wrapper.sh

One common problem with any frequently-running cron job is that a small problem can cause job processes to accumulate until the host is saturated. Only use this technique if you are certain that your job is doing something that is very fast. You should also consider using flock to actively ensure multiple copies of your job can't be run at the same time. You could use flock in the bash script above, on the same line where we invoke the send-updates.py command, or you can add flock to the every-minute crontab entry that invokes the bash script:

* * * * * flock -n /home/crons/send-updates-wrapper.lock /home/crons/send-updates-wrapper.sh

Better support beyond Linux cron

As useful as Linux cron is, it was not created for this level of schedule granularity. A runtime scheduler can express a 30-second interval directly. A few that are commonly available:

SchedulerPlatformLink
Spring CronJava (Quartz)Docs
node-cronNode.jsNPM and GitHub
Go CronGolangReadme
SystemD TimerLinuxExample OnCalendar=*-*-* *:*:00,30

Monitoring your frequent cron jobs

cronitor sync reads the crontab line, which is the wrapper, once a minute. It does not see the two commands inside the script. cronitor discover is an alias of sync and has the same limit. To record each run, call cronitor exec from the wrapper.

For example, change this line:

python /home/crons/send-updates.py &

To this:

cronitor exec send-updates "python /home/crons/send-updates.py" &

The first ping creates a monitor whose key is send-updates. On the job you can set a name and a schedule of every 30 seconds. A five-field crontab has no seconds field, so it cannot say that itself. The other job schedule formats are in job monitoring.

Want alerts if your cron jobs stop working?

Monitor your cron jobs with Cronitor to easily collect output, capture errors and alert you when something goes wrong.