HOWTO: run cron job in seconds

less than 1 minute read

If you know what cron is, you also know that the minimum time to execute a job is a minute. There is a small trick to execute a cron job every X seconds. For example if you need to run a cron job every 30 seconds (it’s a common case), you can do it adding these lines to crontab:

* * * * * root sh /path/to/  
* * * * * root sleep 30 && sh /path/to/

Both lines execute the job every minute, but the second one waits 30 seconds using sleep command from bash.

If you have any question, comment this post. :)

Tags: ,

Categories: ,


Leave a comment