run command in every 5 second
I would like to run a command at every 5 second , I know if I use crontab job to run schedule job , the min. interval is 1 minute , if I want to run at every 5 second ( 12 times / minute ) , what can i do ? thx
|
Quote:
i think you can use the while true command.. while true do command sleep 5(seconds) done the 5 indicates time in seconds then you can just save your simple script in a file... |
You could write a shell-script which executes your command and waits for five seconds in an endless loop.
This you can then start using & to have it detach from the TTY. Or run it inside screen if you want to have the possibility to get back to it, like for checking output for example. Example 1: Code:
#!/bin/sh Example 2: Code:
#!/bin/sh |
Quote:
Could you explain a reason to do it ? May be it'll be better to re-write this program as long-living program, that do each 5 sec whatever your like |
In a shell script you probably have to stick with the 'sleep' command. In a compiled program (C/C++ or similar) you have more fine-grained control about timing.
Maybe it is more efficient in terms of system resources to make the code event-based with some simple server-client programming. The Wrox "Linux Programming" has a good example for this. Linux Archive |
Here's the solution
http://wiki.junkemailfilter.com/inde...nds_under_cron
Code:
#! /bin/sh |
All times are GMT -5. The time now is 06:54 AM. |