linux 关于休眠得脚本,linux – 如果条件为true,请将cron作业休眠5分钟
你有兩個選擇來獲得這個.通常,cron與前一個作業實例是否仍在運行無關.
選項1:
在腳本的開頭寫一個鎖文件,并在完成后將其刪除.然后在腳本開頭檢查文件是否存在,如果是,則腳本結束而不做任何事情.例如,這可能是這樣的:
# if the file exists (`-e`) end the script:
[ -e "/var/lock/myscript.pid" ] && exit
# if not create the file:
touch /var/lock/myscript.pid
...
# do whatever the script does.
# if condition
sleep 300 # wait 5 min
...
# remove the file when the script finishes:
rm /var/lock/myscript.pid
選項2:
這也很有用.它被稱為run-one.從聯機幫助頁:
run-one – run just one instance at a time of some command and unique
set of arguments (useful for cronjobs,eg)
然后cronjob可能如下所示:
* * * * * /usr/bin/run-one /path/to/myscript
總結
以上是生活随笔為你收集整理的linux 关于休眠得脚本,linux – 如果条件为true,请将cron作业休眠5分钟的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么说iOS 16.2 RC版非常值得
- 下一篇: gta5中文怎么设置(gta5如何设置为