Run cron job every two seconds

4 posts / 0 new
Last post
#1 Mon, 05/02/2011 - 13:18
Fredrik-s

Run cron job every two seconds

Hello,

I wonder how I can set a cron job to run every two seconds. Under "Webmin > System > Scheduled cron job" I can set a script to run every minute, but not every two seconds.

How do I accomplish this?

Greetings Fredrik-s

Mon, 05/02/2011 - 14:37
Fredrik-s

Just read that this is not possible.

One work around is to make a loop with a sleep function. Counting down.

Mon, 05/02/2011 - 16:37
andreychek

Howdy,

Yeah, you're correct, Cron doesn't handle frequencies less than one per minute.

As you saw -- the only way to do that would be to write some code of your own that handled running your program every two seconds.

-Eric

Tue, 05/03/2011 - 16:14
Locutus

Considering that cron needs to start processes for the tasks it performs, it'd probably not be a good idea to have it run something every two seconds, even if it was possible. :)

A loop script that stays active and yields CPU cycles for two seconds each time it finishes its thing is much better.

Topic locked