
hi, is there anyway to get crontab (or something else) to do things every few seconds? the smallest unit of time crontab has seems to be minutes. thank you, xiaolei

On Tuesday 03 September 2002 00.55, propheci wrote:
is there anyway to get crontab (or something else) to do things every few seconds? the smallest unit of time crontab has seems to be minutes.
crond only runs once per minute as you guessed. AFAICS atd can also only be set to minute precision. If you want something done with X second intervals, you could do something like this in a script #!/bin/bash while true; do execute_your_program sleep X done Or you could do it in a C program, using something like setitimer with ITIMER_REAL, which may get you a little closer to 3-second interval execution, but it still won't be guaranteed accurate, and you could potentially run into tricky reentrancy problems if your code hasn't finished by the time it's called again (who knows, in a multitasking environment it may not even have started in three seconds) I suspect if you need it done every three seconds with any degree of accuracy you're going to have to use one of the real time extensions to linux, such as RTLinux. Normal "user mode" linux doesn't have that level of accuracy due to its multitasking nature. regards Anders
participants (2)
-
Anders Johansson
-
propheci