Skip to content

Cron schedule

Cron every 30 seconds

Cron's smallest step is one minute, but two crontab lines (or one Laravel method) get you a run every 30 seconds.

What it does

Cron cannot run more often than once a minute. To run something every 30 seconds, run it every minute and once more after a 30-second sleep, or use Laravel's sub-minute schedules (Laravel 10+), which keep schedule:run alive for the whole minute.

Crontab line

Add it with crontab -e over SSH. Replace the path with your script; the redirect keeps cron from emailing you the output.

* * * * * /path/to/command
* * * * * sleep 30; /path/to/command

In Laravel

Define the task in routes/console.php (Laravel 11 and 12):

use Illuminate\Support\Facades\Schedule;

Schedule::command('reports:send')->everyThirtySeconds();

Then add the scheduler's single crontab entry once; it checks every task each minute:

* * * * * cd /path/to/your-app && php artisan schedule:run >> /dev/null 2>&1

In cPanel

  1. Open Cron Jobs under Advanced.
  2. Add the first line with all five fields set to *, then a second one with the same fields and sleep 30; before the command.
  3. In Command, use the full path to PHP, for example /usr/local/bin/php /home/user/app/artisan schedule:run.
  4. Click Add New Cron Job. Some hosts limit how often cron may run; check your plan if it seems to skip runs.

Frequently asked questions

Can cron run every 30 seconds?

No. The smallest unit in a crontab is one minute. Add two lines that both run every minute, with sleep 30 before the command in the second one, or let a long-running worker (a loop or a queue worker) handle it.

How does Laravel run tasks every 30 seconds?

With ->everyThirtySeconds() (Laravel 10 and later). The usual every-minute schedule:run entry stays the same; Laravel keeps the scheduler running for the whole minute and starts the task twice.

Will a shared host allow this?

Many shared hosts only allow cron every 5 or 15 minutes and kill long-running processes. Check your host's limits before relying on sub-minute schedules.

Get new articles in your inbox

Practical tutorials and deep dives, about once a week. No spam, unsubscribe anytime.

Privacy policy

Add DEV Talk to your Home Screen

  1. 1 Tap the Share button in Safari's toolbar.
  2. 2 Scroll down and tap Add to Home Screen.
  3. 3 Tap Add. Open it from the Home Screen to read like an app and to turn on notifications with the bell.

We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.