bash X 分钟后脚本重复自身
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7872789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Script repeat itself after X minutes
提问by Aaron
I have a bash script in Ubuntu, I want it to run every 10 minutes for example after it's done. How can I do this? Thanks!
我在 Ubuntu 中有一个 bash 脚本,我希望它在完成后每 10 分钟运行一次。我怎样才能做到这一点?谢谢!
回答by another.anon.coward
You can check watch.
From the man pages of watchthe description says watch - execute a program periodically, showing output fullscreen, you can try watch -n 600 my_script.shwhich will execute myscript.shevery 600 seconds i.e. 10 minutes. watchshows the output to full screen, you can redirect it to say /dev/nullin case you are not interested in the output to the screen.
Hope this helps!
你可以检查watch。
从描述的手册页中watchwatch - execute a program periodically, showing output fullscreen可以看出,您可以尝试每 600 秒watch -n 600 my_script.sh执行myscript.sh一次,即 10 分钟。watch将输出显示为全屏,/dev/null如果您对输出到屏幕不感兴趣,您可以将其重定向。
希望这可以帮助!
回答by Abhijeet Rastogi
Cronjobs is what you need.
Cronjobs 正是您所需要的。
My blog post:- http://linux-junky.blogspot.com/2010/10/guide-to-add-cronjob-simplified.html
我的博文:- http://linux-junky.blogspot.com/2010/10/guide-to-add-cronjob-simplified.html
Or you can also use sleep 600in your script.
或者您也可以在脚本中使用sleep 600。
回答by glenn Hymanman
回答by Refael
Or with crontab -e, or another option, to check the date. for example, if you want to do something every 10 minutes, you can write:
或者使用 crontab -e 或其他选项来检查日期。例如,如果你想每 10 分钟做一件事,你可以这样写:
##代码##
