Cron - How can I create a cronjob that runs every 15 seconds?

I think you have to write a shell script which calls your command and then sleeps 15 seconds -- I don't believe most cron implementations allow for more than one minute granularity.


Cron mandates the seconds to be there, as far as I knew.

"0/15 * * * * *"

sec min hour day-month month day-week (optional year which I left out)

EDIT: It appears that while the CRON expression requires 6 or 7, the cron exec that runs it wants 5... I'll look into this!


This is really a programming question and as such was asked on the correct site.

As cron itself cannot do what you require it's a matter of creating your own routine. The use of sleep, as suggested by others, will not give the correct results, as it does not take into account the time required to run the command. However, it's a simple matter of reading the system clock, in whatever language suits you, and firing off the command every 15 seconds based on the time, rather than a time delay.

Once you have your routine don't fire it off via cron every minute. Just run it as a background task continuously.

Tags:

Cron