Back to blog
Linux & Servers Published August 20, 2026•Updated November 10, 2026

How to Run a Cron Job Every 10 Seconds in Linux

Automate WhatsApp Alerts
Start Free ➔

Quick answer: cron can't schedule anything more often than once a minute, but you can start the same command six times a minute with different delays. Add these six lines with crontab -e:

* * * * * /path/to/job.sh
* * * * * sleep 10; /path/to/job.sh
* * * * * sleep 20; /path/to/job.sh
* * * * * sleep 30; /path/to/job.sh
* * * * * sleep 40; /path/to/job.sh
* * * * * sleep 50; /path/to/job.sh

On a server with systemd, a systemd timer (Method 2) is cleaner: one setting, logs in journalctl, and no overlapping runs.

Cron's schedule has five fields (minute, hour, day of month, month, day of week) and no field for seconds. Everything below is a way around that.


Method 1: Six Offset Crontab Lines

The lines in the quick answer all start at the top of each minute; each one waits a different number of seconds before running the job, so the job starts at :00, :10, :20, :30, :40 and :50.

Things to know:

  • Runs can overlap. If the job sometimes takes longer than 10 seconds, the next one starts anyway. Wrap the job in flock so a run is skipped while the previous one is still going:

    * * * * * sleep 10; flock -n /tmp/job.lock /path/to/job.sh
    
  • Timing is approximate. Cron starts jobs within the first second or so of the minute, so expect a second of variation.

  • Use full paths. Cron runs with a minimal PATH, so call /usr/bin/python3, not python3.


Method 2: A systemd Timer (Recommended)

A timer starts a service at a fixed interval. Create two files.

/etc/systemd/system/every10s.service:

[Unit]
Description=Job that runs every 10 seconds

[Service]
Type=oneshot
ExecStart=/path/to/job.sh
User=www-data

/etc/systemd/system/every10s.timer:

[Unit]
Description=Run every10s.service every 10 seconds

[Timer]
OnBootSec=10s
OnUnitActiveSec=10s
AccuracySec=1s

[Install]
WantedBy=timers.target

Enable it:

sudo systemctl daemon-reload
sudo systemctl enable --now every10s.timer
systemctl list-timers every10s.timer     # shows the next and last run
journalctl -u every10s.service -n 20     # output of recent runs

What the settings mean:

  • OnUnitActiveSec=10s starts the job 10 seconds after it last started. Use OnUnitInactiveSec=10s instead if you want a 10-second gap after each run finishes.
  • AccuracySec=1s: systemd groups timers together and may delay them by up to AccuracySec, which is 1 minute by default. Lower it, or a "10-second" timer can drift badly.
  • Type=oneshot: the job runs, exits, and the timer starts it again. While a run is still active, systemd doesn't start a second copy, so runs never overlap.

Method 3: A Loop in a Long-Running Service

If the job is really a worker that should run all the time, write it as a loop and let systemd keep it alive:

#!/bin/bash
# /usr/local/bin/every10s-loop.sh
while true; do
    /path/to/job.sh
    sleep 10
done
# /etc/systemd/system/every10s-loop.service
[Unit]
Description=Loop that runs the job every 10 seconds

[Service]
ExecStart=/usr/local/bin/every10s-loop.sh
Restart=always
User=www-data

[Install]
WantedBy=multi-user.target

Here the gap between runs is 10 seconds plus however long the job takes. Avoid starting the loop with nohup ... & from a terminal: it won't come back after a reboot or a crash.


Which One to Use

Six crontab linessystemd timerLoop service
SetupSimplestTwo small filesScript plus service
Overlapping runsPossible (use flock)NeverNever
TimingAbout ±1 secondAccurate once AccuracySec is loweredDrifts by the job's run time
LogsWherever you redirect themjournalctljournalctl
After a crash or rebootNext minuteNext intervalRestarted by systemd

Know when the job stops running

High-frequency jobs fail quietly: a lock never released, a full disk, a typo in an update. Nothing errors loudly; the work just stops.

A heartbeat check catches this. Have the job call a URL when it succeeds, and get alerted when the calls stop. With Pingzo, heartbeat (cron) monitors are available on the Pro and Agency plans. Pingzo accepts at most one success ping every 30 seconds, so for a 10-second job send the ping once a minute (for example only from the run at :00) rather than from every run. If no ping arrives within the interval plus the grace period you set, you get an alert on WhatsApp, Slack, Telegram, Discord or email.


Related guides

Zero-Code Uptime Alerts

Stop Finding Out About Outages from Angry Users

Get instant WhatsApp & Discord alerts the second your API, website, or server goes down. Setup in 30 seconds, with checks as often as every minute.

WhatsApp & Discord 60-Second Checks Free Forever Plan
Try Pingzo Free

Know before your users do

Connect official WhatsApp notification channels, Discord webhooks, Telegram bots, and public status pages. Start in 30 seconds.

Create Free Monitor