- 论坛徽章:
- 0
|
目前就我所知,有两种方法可以实现定时任务,一种是OS级别的,另外一种是application级别的。
具体来说,OS是Solaris,而application则是Oracle Database Jobs。
今天我们讨论OS上的定时任务,在Solaris上,叫crontab。具体内容可以查看man crontab。
需要注意的是crontab有两个文件来决定你是否可以使用crontab命令:
/etc/cron.d/cron.allow 和
/etc/cron.d/cron.deny
其决定关系是,看来还是用man最权威了:
----------------------------
crontab Access Control
Users: Access to crontab is allowed:
o if the user's name appears in /etc/cron.d/cron.allow.
o if /etc/cron.d/cron.allow does not exist and the
user's name is not in /etc/cron.d/cron.deny.
Users: Access to crontab is denied:
o if /etc/cron.d/cron.allow exists and the user's name
is not in it.
o if /etc/cron.d/cron.allow does not exist and user's
name is in /etc/cron.d/cron.deny.
o if neither file exists, only a user with the
solaris.jobs.user authorization is allowed to submit a
job.
o If BSM audit is enabled, the user's shell is not
audited and the user is not the crontab owner. This
can occur if the user logs in via a program, such as
some versions of SSH, which does not set audit parame-
ters.
Notice that the rules for allow and deny apply to root only
if the allow/deny files exist.
The allow/deny files consist of one user name per line.
----------------------------
那么现在就是使用crontab了,最简单的做法就是 crontab -e进入编辑界面,类似vi命令去操作,然后按照其规定的格式填写即可。
前五个字段可以取整数值,指定何时开始工作,第六个域是字符串,称为命令字段,其中包括了crontab调度执行的命令。
第一个字段:0~59 表示分
第二个字段:1~23 表示小时
第三个字段:1~31 表示日
第四个字段:1~12 表示月份
第五个字段:0~6 表示星期(其中0表示星期日)
第六个字段:命令开始
1 * * * * date >> /export/home/oracht01/data.record
要查看crontab的内容,则用crontab -l即可。
End of Session
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/1914/showart_158391.html |
|