加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

如何更改cron.daily在linux中运行的时间

发布时间:2020-12-13 18:36:52 所属栏目:Linux 来源:网络整理
导读:我在cron.daily中有一个脚本,每天早上在某个时间运行.我需要改变运行的时间. 如何更改cron.daily运行脚本的时间? 解决方法 在Red Hat 5或更早版本中,这是在/ etc / crontab中控制的. 较新的版本使用 /etc/anacrontab .默认情况下,cron.daily脚本在4:02运行.
我在cron.daily中有一个脚本,每天早上在某个时间运行.我需要改变运行的时间.

如何更改cron.daily运行脚本的时间?

解决方法

在Red Hat 5或更早版本中,这是在/ etc / crontab中控制的.

较新的版本使用/etc/anacrontab.默认情况下,cron.daily脚本在4:02运行.编辑/ etc / crontab将修改该时间.

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

在Debian / Ubuntu系统上,这也在/ etc / crontab中控制.

例如;默认的Ubuntu 12.04安装:

# /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 )
#

在任何一种情况下,您可以在此处找到有关使用何种语法的更多详细信息:http://linux.die.net/man/5/crontab或在几乎任何Linux系统上运行man 5 crontab.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读