免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1221 | 回复: 0
打印 上一主题 下一主题

Solaris上的crontab使用 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-21 15:17 |只看该作者 |倒序浏览
目前就我所知,有两种方法可以实现定时任务,一种是OS级别的,另外一种是application级别的。

具体来说,OSSolaris,而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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP