11 月 302012
 

安装计划任务服务
#yum install crontabs

查看crond系统服务运行状态
[root@oracle ~]# service crond status
crond (pid 1918) is running…
[root@oracle ~]#

CentOS6.3最小化安装环境下的依赖包关系
Dependencies Resolved

===============================================================================

=
Package Arch Version Repository Size
===============================================================================

=
Installing:
crontabs noarch 1.10-33.el6 base 10 k
Installing for dependencies:
cronie x86_64 1.4.4-7.el6 base 70 k
cronie-anacron x86_64 1.4.4-7.el6 base 29 k
cyrus-sasl x86_64 2.1.23-13.el6 base 78 k
hesiod x86_64 3.1.0-19.el6 base 20 k
procmail x86_64 3.22-25.1.el6 base 163 k
sendmail x86_64 8.14.4-8.el6 base 717 k

Transaction Summary
===============================================================================

=
Install 7 Package(s)

限制用户使用计划任务

当cron.allow文件存在,列出的用户被允许使用,同时忽略cron.deny文件
当cron.allow文件不存在,在cron.deny中列出的用户都被禁止使用计划任务
每行一个用户,修改后必须重启crond服务
#ls /etc/cron.allow(CentOS6.3最小化安装默认不存在此文件)
#ls /etc/cron.deny

查看系统定义计划任务配置文件存储目录
[root@oracle ~]# ls /etc/cron.
cron.d/ cron.deny cron.monthly/
cron.daily/ cron.hourly/ cron.weekly/
[root@oracle ~]#

关于CenOS6.3中run-parts的说明
#man 4 crontabs
Historically the crontab file contained configuration which called run-parts on

files in cron.{daily,weekly,monthly} directories. These jobs are now run

indirectly through anacron to prevent conflicts between cron and anacron.

That means the anacron package has to be installed if the jobs in these

directories should be running. Refer to the anacron(8) how to limit the time of

day of the job execution.

以前包含在crontab文件中的用以配置cront.{daily,weekly,month}目录的run-parts配置

,已经改由anacron服务来管理,以此避免cron和anacron的冲突,这也就意味着,如果要

运行这些目录中的计划任务,就有必要安装anacron服务。

查看全局crontab配置文件
#cat /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

用户级别计划任务设置
[root@oracle ~]# crontab -e

查看用户级别计划任务配置文件
[root@oracle ~]# ls /var/spool/cron/
root
[root@oracle ~]# cat /var/spool/cron/root
#Configuration for cron By Root
[root@oracle ~]#

列出当前计划任务
[root@oracle ~]# crontab -l

五个星号所代表的单位及可用值
*(分钟0-59) *(小时0-23) *(日1-31) *(月1-12) *(周0-6)

月可用英文简写
周日可用0或7代替,可用英文简写

示例
1 * * * *
每小时第一分钟

*/1 * * * *
每一分钟

* 1 * * *
每天1点钟

15 1 * * *
每天1点15分

* */1 * * *
每一小时

15 1 * * 1-5
每周一至周五的1点15分

英文月份与星期的全拼与简写
January Jan
February Feb
March Mar
April Apr
May May
June June
July July
August Aug
September Sept
October Oct
November Nov
December Dec

Monday Mon
Tuesday Tue
Wednesday Wed
Thursday Thur
Friday Fri
Saturday Sat
Sunday Sun

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据