Run a cron job more than every minute

The standard cron syntax lets you specify the minute(s) at which a task runs, but you cannot specify an interval less than once a minute (using * * * * * *).

You can run a cron job more than by a minute by creating a simple shell script that repeatedly runs the task, with a sleep command between each call to the job.

Like we want to run the crob after every 15 seconds then code of scripts looks like

#!/bin/sh
open /path/to/cronfile
sleep 15
open /path/to/cronfile
sleep 15
open /path/to/cronfile
sleep 15
open /path/to/cronfile
sleep 15

This will run the task four times in a minute. after making this script we can make a file which will call above script with the interval set to every minute.

In summary, if you need a cron task to run more than once a minute, create a simple shell script using sleep, and have it call your other task the required number of times per minute, then tell cron to run that shell script.

If you like the post & want to get more then Subscribe our blog posts. Subscribe SunwareTech.net RSS Feed Facebook Twitter Email

Both comments and pings are currently closed.

Comments are closed.

Copyright © Sunware Technologies - Your web partner