lam*_*ins 3 linux ubuntu process cron
我有几个简单的 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
#
Run Code Online (Sandbox Code Playgroud)
我确实通过exicuting检查了cron是否运行了两次,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
Run Code Online (Sandbox Code Playgroud)
那么这是怎么回事,我该如何预防呢?
感谢您的任何帮助。
首先,你的结论是有两个cron过程是错误的。你的输出中有一个cron和一个grep。
接下来,您说引用的文件在您的根 crontab 中。你引用的内容说它在/etc/crontab. 那么,这是/etc/crontab或的内容crontab -l -u root吗?这是两个截然不同的东西。
如果两者兼而有之,那么你就告诉它在一个地方运行这些东西,然后在另一个地方运行,所以两次。您可能想从 root 的 crontab 中将其全部删除。
| 归档时间: |
|
| 查看次数: |
2762 次 |
| 最近记录: |