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

前端之家收集整理的这篇文章主要介绍了如何更改cron.daily在linux中运行的时间前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在cron.daily中有一个脚本,每天早上在某个时间运行.我需要改变运行的时间.

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

解决方法

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

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

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

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

例如;默认的Ubuntu 12.04安装:

  1. # /etc/crontab: system-wide crontab
  2. # Unlike any other crontab you don't have to run the `crontab'
  3. # command to install the new version when you edit this file
  4. # and files in /etc/cron.d. These files also have username fields,# that none of the other crontabs do.
  5.  
  6. SHELL=/bin/sh
  7. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  8.  
  9. # m h dom mon dow user command
  10. 17 * * * * root cd / && run-parts --report /etc/cron.hourly
  11. 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
  12. 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
  13. 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
  14. #

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

猜你在找的Linux相关文章