开发者

How do run a Unix command at a given time interval?

I want to run a Unix command (e.g. ls) at 5 minute intervals through a script.

Explanation:

I have a Unix script. In that script I have a command called "ls".

I want that "ls开发者_开发技巧" command to run every 5 minutes from that script.


Use watch. The -n flag specifies interval in seconds, so

watch -n 300 ls


while true; do
    ls
    sleep 300
done

?


Put your script into the Crontab via

crontab -e

More information about Cron you can find at wikipedia


You could use crontab for example. See http://en.wikipedia.org/wiki/Cron

for example i you want to run your script every five minutes via crontab it should look something like this:

#m  h dom mon dow user command
*/5 * *   *   *   root /path/to/script


crontab 

http://en.wikipedia.org/wiki/Cron

or

svc 

http://cr.yp.to/daemontools.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜