Linux   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了linux – 运行两次的Cron作业–Ubuntu服务器12.04大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我有几个简单的cron作业在root下运行.然而,他们似乎跑了两次,我无法弄清楚为什么.没有其他用户运行任何cron作业,唯一的cronfile是root用户.工作完成得很好,但两次. 这是根crontab文件: # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `cro
我有几个简单的cron作业在root下运行.然而,他们似乎跑了两次,我无法弄清楚为什么.没有其他用户运行任何cron作业,唯一的cronfile是root用户.工作完成得很好,但两次.

这是根crontab文件

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. these files also have username fields,# that none of the other crontabs do.

SHelL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * cd / && run-parts --report /etc/cron.hourly
25 6 * * * test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
0,30 * * * * sh /scripts/amsBACkup.sh 
0,15,30,45 * * * * sh /scripts/dbBACkup.sh
#

我确实检查了cron是否通过exicuTing运行了两次,ps aux | grep cron这里是输出,表明有两个进程:

root      9822  0.0  0.0   2620   892 ?        Ss   Dec24   0:01 cron
root     19146  0.0  0.0   3904   788 pts/1    S+   21:27   0:00 grep --color=auto cron

那么发生了什么,我该如何预防呢?

感谢您的任何帮助.

解决方法

首先,你的结论是有两个cron进程是错误的.输出中有一个cron和一个grep.

接下来,您说引用的文件位于根crontab中.你引用的内容它在/ etc / crontab中.那么,/ etc / crontab或crontab -l -u root的内容是什么?这是两个截然不同的事情.

如果它是两者,那么,你告诉它在一个地方然后在另一个地方运行这些东西,那么两次.您可能希望从root的crontab中删除它.

大佬总结

以上是大佬教程为你收集整理的linux – 运行两次的Cron作业–Ubuntu服务器12.04全部内容,希望文章能够帮你解决linux – 运行两次的Cron作业–Ubuntu服务器12.04所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。