【发布时间】:2019-06-11 11:15:35
【问题描述】:
在我的项目中,我想用 cron 做一个计划任务。
所以我在 /etc/crontab 中添加了一行
*/10 * * * * root /home/JobidUserJobname/JobidUserJobname.sh
/etc/crontab 的内容是这样的:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/10 * * * * root /home/JobidUserJobname/JobidUserJobname.sh
*/1 * * * * root date
然后我重新启动 crontab 服务:
#service crond restart
#service crond reload
他们成功执行了。
但是当我执行时:
#crontab -l
它显示:
no crontab for root
好像没什么问题。我的 linux 操作系统是:
CentOS release 6.5 (Final)
谁能帮帮我?
【问题讨论】:
-
这对于Unix & Linux 来说可能是一个更好的问题。这不是一个真正的编程问题(除非您认为
crontab是一种简单的编程语言)。 -
这也可能是这个问题的重复:unix.stackexchange.com/q/127732/10454——你需要了解系统crontab和用户(包括
root)crontab的区别。
标签: cron