问题
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.
回答1:
Use watch
. The -n
flag specifies interval in seconds, so
watch -n 300 ls
回答2:
while true; do
ls
sleep 300
done
?
回答3:
Put your script into the Crontab via
crontab -e
More information about Cron you can find at wikipedia
回答4:
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
回答5:
crontab
http://en.wikipedia.org/wiki/Cron
or
svc
http://cr.yp.to/daemontools.html
来源:https://stackoverflow.com/questions/6758500/how-do-run-a-unix-command-at-a-given-time-interval