正在加载图片...
rootelocalhost /F crontab -1 no crontab fo Irootelocalhost /]F crontab /root/Desktop/iptables, cron@) Irootelocalhost /F crontab -l F crontab /root/Desktop/iptables, cron Eminute hour day-of-month month-of-year day-of-week commands 0081,.2.3,4,5 service iptables restart: sh /root/iptables_ work.sh 30 14.1.2.3. 4.5 service iptables restart: sh /root/iptables work.sh 00 12.1.2.3, 4, 5 service iptables restart: sh /root/iptables rest. sh 30 17,19, 21,23..1.2,3.4, 5 service iptables restart: sh /root/iptables rest. sh 208, 11.14, 17.20, 230.6 service iptables restart: sh /root/iptables_ rest. sh Irootelocalhost / 图3-39创建 crontab cron服务每分钟不仅要读一次/var/ spool/cron内的所有文件,还需要读一次/ etc/crontab, 因此也可以编辑/etc/ crontab文件,使得cron服务在固定的时间执行指定的程序。/etc/ crontab 文件内容如图3-40所示 注意 run-parts命令执行 /etc/cron hourly、etc/ cron daily等目录中的脚本文件 对后4行的说明如下: 01*** root run- parts/etc/ cron hourly∥每小时执行/etc/ cron. hourly内的脚本文件 024*** oot run-parts /etc/cron daily∥每天执行/ etc/cron daily内的脚本文件 224**0 root run- parts/etc/ cron weekly∥每星期执行/ etc/cron weekly内的脚本文件 4241** root run-parts/etc/ cron. monthly每月执行/etc/ cron. monthly内的脚本文件 注意 在 linux系统中,系统本身的 crontab和用户(比如root)的 crontab是有区别的,如果要修 改系统本身的 crontab,可以直接编辑/etc/cron*/下面的文件;如果要修改用户(比如root)的 crontab,可以执行# crontab crontabfile或# crontab-e命令,并且创建的用户 crontab自动保存 在/ar/ spool/cron目录下 剩辑4直看察③工 run- parts /etc/cron hourly /etc/cron weekly /etc/cron, monthl 图3-4 )文件内容 注意 如果文件/etc/ cron allow存在那么只有在 cron allow中列出的非root用户才能使用cron服 务。如果 cronallow不存在,但是/ etc/crondeny存在,那么在 crondeny中列出的非root用户 不能使用cron服务,如果 crondeny文件为空,那么所有用户都能使用cron服务。如果这两个文 件都不存在那么只允许root用户使用con服务下面介绍的at命剑/etc/ t allow、/etc/ atdeny) 与此类似。图3-39 创建crontab cron服务每分钟不仅要读一次/var/spool/cron内的所有文件,还需要读一次/etc/crontab, 因此也可以编辑/etc/crontab文件,使得cron服务在固定的时间执行指定的程序。/etc/crontab 文件内容如图3-40所示。 注意: run-parts 命令执行/etc/cron.hourly、/etc/cron.daily 等目录中的脚本文件。 对后4行的说明如下: 01 * * * * root run-parts /etc/cron.hourly //每小时执行/etc/cron.hourly内的脚本文件 02 4 * * * root run-parts /etc/cron.daily //每天执行/etc/cron.daily内的脚本文件 22 4 * * 0 root run-parts /etc/cron.weekly //每星期执行/etc/cron.weekly内的脚本文件 42 4 1 * * root run-parts /etc/cron.monthly //每月执行/etc/cron.monthly内的脚本文件 注意: 在 linux 系统中,系统本身的 crontab 和用户(比如 root)的 crontab 是有区别的,如果要修 改系统本身的 crontab,可以直接编辑/etc/cron.*/下面的文件;如果要修改用户(比如 root)的 crontab,可以执行#crontab crontabfile 或#crontab -e 命令,并且创建的用户 crontab 自动保存 在/var/spool/cron 目录下。 图3-40 /etc/crontab文件内容 注意: 如果文件/etc/cron.allow 存在,那么只有在 cron.allow 中列出的非 root 用户才能使用 cron 服 务。如果 cron.allow 不存在,但是/etc/cron.deny 存在,那么在 cron.deny 中列出的非 root 用户 不能使用 cron 服务,如果 cron.deny 文件为空,那么所有用户都能使用 cron 服务。如果这两个文 件都不存在,那么只允许 root 用户使用 cron 服务。下面介绍的 at 命令(/etc/at.allow、/etc/at.deny) 与此类似
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有