LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1050|回复: 9

我系统的cron怎么压根就不起作用呀????头大呀!!!!

[复制链接]
发表于 2005-8-29 15:35:39 | 显示全部楼层 |阅读模式
系统CRON已经是自动启动Deamon了,我把内容写入了/etc/crontab,但是怎么就是没一点反应呢??
用ps -aux还能看到cron已运行了哦!
crontab中的内容如下:
*/5  * * * * root  /root/mrtg.sh

mrtg.sh是可执行的文件了!
发表于 2005-8-29 18:02:05 | 显示全部楼层
你不妨看看 root 用户有没有收到系统发出的邮件
在我这儿,如果 cron 执行任务时出错,系统会给用户发一封邮件告知出错原因
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-29 20:05:00 | 显示全部楼层
Post by carlos
你不妨看看 root 用户有没有收到系统发出的邮件
在我这儿,如果 cron 执行任务时出错,系统会给用户发一封邮件告知出错原因


苦恼就苦恼在这,没有收到系统发给ROOT的MAIL,LOG日志中也没有相关的东东呀!!
回复 支持 反对

使用道具 举报

发表于 2005-8-29 20:25:59 | 显示全部楼层
Post by spritecat
系统CRON已经是自动启动Deamon了,我把内容写入了/etc/crontab,但是怎么就是没一点反应呢??
用ps -aux还能看到cron已运行了哦!
crontab中的内容如下:
*/5  * * * * root  /root/mrtg.sh

mrtg.sh是可执行的文件了!


*/5 * * * * /root/mrtg.sh
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-30 09:34:33 | 显示全部楼层
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file.
# This file also has a username field, that none of the other crontabs do.

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
MAILTO="root"
# m h dom mon dow user  command
17 *    * * *   root    run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6    * * 7   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6    1 * *   root    test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly
*/5 * * * * root /mrtg/2948g.sh

是要加root的呀
回复 支持 反对

使用道具 举报

发表于 2005-8-30 11:15:28 | 显示全部楼层
你将自己的账号加入crontab组了吗?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-30 16:03:17 | 显示全部楼层
root也要加入crontab组吗?
回复 支持 反对

使用道具 举报

发表于 2005-8-30 20:10:40 | 显示全部楼层
在脚本名称中不能有".",去掉试试看。crontab 里的文件名必须遵循和run-parts一样的的命名规范,参见cron和
run-parts的man page
回复 支持 反对

使用道具 举报

发表于 2006-7-5 10:24:29 | 显示全部楼层
Post by x.f
在脚本名称中不能有".",去掉试试看。crontab 里的文件名必须遵循和run-parts一样的的命名规范,参见cron和
run-parts的man page


有这种事儿?
回复 支持 反对

使用道具 举报

发表于 2006-7-5 10:28:54 | 显示全部楼层
  1. CRONTAB(5)                                                                                                     CRONTAB(5)
  2. NAME
  3.        crontab - tables for driving cron (ISC Cron V4.1)
  4. DESCRIPTION
  5.        A crontab file contains instructions to the cron(8) daemon of the general form: ''run this command at this time on
  6.        this date''.  Each user has their own crontab, and commands in any given crontab will be executed as the user  who
  7.        owns the crontab.  Uucp and News will usually have their own crontabs, eliminating the need for explicitly running
  8.        su(1) as part of a cron command.
  9.        Blank lines and leading spaces and tabs are ignored.  Lines whose first non-space character is  a  pound-sign  (#)
  10.        are  comments,  and are ignored.  Note that comments are not allowed on the same line as cron commands, since they
  11.        will be taken to be part of the command.  Similarly, comments are not allowed on  the  same  line  as  environment
  12.        variable settings.
  13.        An active line in a crontab will be either an environment setting or a cron command.  An environment setting is of
  14.        the form,
  15.            name = value
  16.        where the spaces around the equal-sign (=) are optional, and any subsequent non-leading spaces in  value  will  be
  17.        part  of the value assigned to name.  The value string may be placed in quotes (single or double, but matching) to
  18.        preserve leading or trailing blanks.
  19.        Several environment variables are set up automatically by the cron(8) daemon.  SHELL is set to /bin/sh,  and  LOG-
  20.        NAME  and HOME are set from the /etc/passwd line of the crontab's owner.  HOME and SHELL may be overridden by set-
  21.        tings in the crontab; LOGNAME may not.
  22.        (Another note: the LOGNAME variable is sometimes called USER on BSD systems...  on these systems, USER will be set
  23.        also.)
  24.        In addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO if it has any reason to send mail as a result
  25.        of running commands in ''this'' crontab.  If MAILTO is defined (and non-empty), mail is sent to the user so named.
  26.        If  MAILTO  is  defined  but  empty (MAILTO=""), no mail will be sent.  Otherwise mail is sent to the owner of the
  27.        crontab.  This option is useful if you decide on /bin/mail instead of /usr/lib/sendmail as your  mailer  when  you
  28.        install cron -- /bin/mail doesn't do aliasing, and UUCP usually doesn't read its mail.
  29.        The  format  of  a cron command is very much the V7 standard, with a number of upward-compatible extensions.  Each
  30.        line has five time and date fields, followed by a user name if this is the system crontab file, followed by a com-
  31.        mand.   Commands  are  executed by cron(8) when the minute, hour, and month of year fields match the current time,
  32.        and at least one of the two day fields (day of month, or day of week) match the current time (see ''Note'' below).
  33.        Note  that  this  means  that non-existent times, such as "missing hours" during daylight savings conversion, will
  34.        never match, causing jobs scheduled during the "missing times" not to be run.  Similarly, times  that  occur  more
  35.        than once (again, during daylight savings conversion) will cause matching jobs to be run twice.
  36.        cron(8) examines cron entries once every minute.
  37.        The time and date fields are:
  38.               field          allowed values
  39.               -----          --------------
  40.               minute         0-59
  41.               hour           0-23
  42.               day of month   1-31
  43.               month          1-12 (or names, see below)
  44.               day of week    0-7 (0 or 7 is Sun, or use names)
  45.        A field may be an asterisk (*), which always stands for ''first-last''.
  46.        Ranges of numbers are allowed.  Ranges are two numbers separated with a hyphen.  The specified range is inclusive.
  47.        For example, 8-11 for an ''hours'' entry specifies execution at hours 8, 9, 10 and 11.
  48.        Lists are allowed.  A list is  a  set  of  numbers  (or  ranges)  separated  by  commas.   Examples:  ''1,2,5,9'',
  49.        ''0-4,8-12''.
  50.        Step  values  can be used in conjunction with ranges.  Following a range with ''/<number>'' specifies skips of the
  51.        number's value through the range.  For example, ''0-23/2'' can be used in the hours field to specify command  exe-
  52.        cution  every  other  hour  (the alternative in the V7 standard is ''0,2,4,6,8,10,12,14,16,18,20,22'').  Steps are
  53.        also permitted after an asterisk, so if you want to say ''every two hours'', just use ''*/2''.
  54.        Names can also be used for the ''month'' and ''day of week'' fields.  Use the first three letters of the  particu-
  55.        lar day or month (case doesn't matter).  Ranges or lists of names are not allowed.
  56.        The  ''sixth''  field  (the  rest of the line) specifies the command to be run.  The entire command portion of the
  57.        line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL  variable
  58.        of  the  cronfile.  Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into new-
  59.        line characters, and all data after the first % will be sent to the command as standard input.
  60.        Note: The day of a command's execution can be specified by two fields -- day of month, and day of  week.   If  both
  61.        fields  are  restricted  (ie,  aren't *), the command will be run when either field matches the current time.  For
  62.        example,
  63.        ''30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
  64. EXAMPLE CRON FILE
  65.        # use /bin/sh to run commands, no matter what /etc/passwd says
  66.        SHELL=/bin/sh
  67.        # mail any output to 'paul', no matter whose crontab this is
  68.        MAILTO=paul
  69.        #
  70.        # run five minutes after midnight, every day
  71.        5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1
  72.        # run at 2:15pm on the first of every month -- output mailed to paul
  73.        15 14 1 * *     $HOME/bin/monthly
  74.        # run at 10 pm on weekdays, annoy Joe
  75.        0 22 * * 1-5   mail -s "It's 10pm" joe%Joe,%%Where are your kids?%
  76.        23 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday"
  77.        5 4 * * sun     echo "run at 5 after 4 every sunday"
  78. FILES
  79.        /etc/crontab   System crontab file
  80. SEE ALSO
  81.        cron(8), crontab(1)
  82. EXTENSIONS
  83.        When  specifying  day of week, both day 0 and day 7 will be considered Sunday.  BSD and ATT seem to disagree about
  84.        this.
  85.        Lists and ranges are allowed to co-exist in the same field.  "1-3,7-9" would be rejected by ATT  or  BSD  cron  --
  86.        they want to see "1-3" or "7,8,9" ONLY.
  87.        Ranges can include "steps", so "1-9/2" is the same as "1,3,5,7,9".
  88.        Names of months or days of the week can be specified by name.
  89.        Environment  variables  can  be  set  in the crontab.  In BSD or ATT, the environment handed to child processes is
  90.        basically the one from /etc/rc.
  91.        Command output is mailed to the crontab owner (BSD can't do this), can be  mailed  to  a  person  other  than  the
  92.        crontab  owner  (SysV can't do this), or the feature can be turned off and no mail will be sent at all (SysV can't
  93.        do this either).
  94.        These special time specification "nicknames" are supported, which replace the 5 initial time and date fields,  and
  95.        are prefixed by the '@' character:
  96.        @reboot    :    Run once, at startup.
  97.        @yearly    :    Run once a year, ie.  "0 0 1 1 *".
  98.        @annually  :    Run once a year, ie.  "0 0 1 1 *".
  99.        @monthly   :    Run once a month, ie. "0 0 1 * *".
  100.        @weekly    :    Run once a week, ie.  "0 0 * * 0".
  101.        @daily     :    Run once a day, ie.   "0 0 * * *".
  102.        @hourly    :    Run once an hour, ie. "0 * * * *".
  103. CAVEATS
  104.        In  this  version of cron, /etc/crontab must not be writable by any user other than root.  No crontab files may be
  105.        links, or linked to by any other file.  No crontab files may be executable, or be writable by any user other  than
  106.        their owner.
  107. AUTHOR
  108.        Paul Vixie <vixie@isc.org>
  109. 4th Berkeley Distribution                            24 January 1994                                           CRONTAB(5)
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表