LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   cron jobs for less than a minute (http://www.linuxquestions.org/questions/linux-general-1/cron-jobs-for-less-than-a-minute-806691/)

golden_boy615 05-08-2010 03:16 PM

cron jobs for less than a minute
 
hello
how can I cron jobs for less than a minute for example configuring cron job to do something for each 15 seconds.

frostschutz 05-08-2010 04:22 PM

cron jobs is meant for stuff that runs every couple of hours, or even days, weeks, months, so doing something every minute is the best it can do

if you want to do something every 15 seconds, you could make a shell script and sleep instead

Code:

while [ 1 ]
do
    something
    sleep 15
done


golden_boy615 05-09-2010 02:42 AM

Is any way except that? it makes busy waiting for that.

druuna 05-09-2010 04:18 AM

Hi,

The shortest time interval you can use with cron is 1 minute.

frostschutz's solution works, although you will introduce a sliding window (the next run will be 15 seconds + runtime of "something").

Hope this helps.

MTK358 05-09-2010 06:55 AM

The sleep command does NOT busy wait, at least my version doesn't. I just tried it.


All times are GMT -5. The time now is 09:29 PM.