永发信息网

怎么使用crontab计划任务

答案:1  悬赏:60  手机版
解决时间 2021-01-26 15:33
  • 提问者网友:不爱我么
  • 2021-01-26 04:31
怎么使用crontab计划任务
最佳答案
  • 五星知识达人网友:雪起风沙痕
  • 2021-01-26 05:16
一、系 统的Cron计划文件存放在/etc/crontab路径下。与用户的crontab文件不同,root用户可以直接对该文件进行修改,而不用使用 crontab -e命令。除此之外,系统crontab文件中任务的定义也有所不同,在前五个部分之后插入了一个“用户”部分。以下是我的/etc/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 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
二、使设置生效
设置完成后,重启cron即可使设置的计划任务定时执行了,重启命令如下:
service cron restart
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯