我有4台服务器,我希望每台服务器在周日执行重启.
>服务器1 – 本月的第一个星期日(第一周)
>服务器2 – 本月的第二个星期日(第2周)
>服务器3 – 本月第三个星期日(第3周)
>服务器4 – 本月的第四个星期日(第4周)
我怎么能用Crontab做到这一点?
谢谢!
多坦.
10 1 1-7 * * test `date +\%a` == "Sun" && doSomething
在1日和7日之间的星期日,将在1点10分运行doSomething.类似地,第二个星期日将介于8日和14日之间,第三个星期日介于15日和21日之间,第四个星期日介于22日和28日之间,因此在相关服务器上相应地调整日期.
请注意,测试是必需的,因为
总结Note: The day of a command’s execution can be specifIEd by two fIElds — day of month,and day of week. If both fIElds are restricted (IE,aren’t *),the command will be run when either fIEld matches the cur- rent time. For example,“30 4 1,15 * 5” would cause a command to be run at 4:30 am on the 1st and 15th of each month,plus every FrIDay.
以上是内存溢出为你收集整理的linux – 如何使用crontab 在月份的第一,第二,第三和第四个星期日执行命令全部内容,希望文章能够帮你解决linux – 如何使用crontab 在月份的第一,第二,第三和第四个星期日执行命令所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)