{
    "mode": "man",
    "parameter": "crontab",
    "section": "5",
    "url": "https://www.chedong.com/phpMan.php/man/crontab/5/json",
    "generated": "2026-08-21T15:27:04Z",
    "sections": {
        "NAME": {
            "content": "crontab - tables for driving cron\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "A  crontab  file  contains instructions to the cron(8) daemon of the general form: ``run this\ncommand at this time on this date''.  Each user has their own crontab, and  commands  in  any\ngiven  crontab will be executed as the user who owns the crontab.  Uucp and News will usually\nhave their own crontabs, eliminating the need for explicitly running su(1) as part of a  cron\ncommand.\n\nNote  that  comments on the same line as cron commands are not interpreted as comments in the\ncron sense, but are considered part of the command and passed to the shell. This is similarly\ntrue for comments on the same line as environment variable settings.\n\nAn active line in a crontab will be either an environment setting or a cron command.  An  en‐\nvironment setting is of the form,\n\nname = value\n\nwhere  the  spaces  around  the  equal-sign  (=) are optional, and any subsequent non-leading\nspaces in value will be part of the value assigned to name.  The value string may  be  placed\nin quotes (single or double, but matching) to preserve leading or trailing blanks.  To define\nan empty variable, quotes must be used.\n\nThe value string is not parsed for environmental substitutions or replacement of variables or\ntilde(~) expansion, thus lines like\n\nPATH=$HOME/bin:$PATH\nPATH=~/bin:/usr/bin\n\nwill not work as you might expect. And neither will this work\n\nA=1\nB=2\nC=$A $B\n\nThere will not be any substitution for the defined variables in the last value. However, with\nmost shells you can also try e.g.,:\n\nP=PATH=/a/b/c:$PATH\n33 22 1 2 3 eval $P && some commands\n\nSeveral  environment  variables are set up automatically by the cron(8) daemon.  SHELL is set\nto /usr/bin/sh, and LOGNAME and HOME are set from  the  /etc/passwd  line  of  the  crontab's\nowner.  HOME and SHELL may be overridden by settings in the crontab; LOGNAME may not.\n\n(Another note: the LOGNAME variable is sometimes called USER on BSD systems...  on these sys‐\ntems, USER will be set also.)\n\nIn  addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO if it has any reason to\nsend mail as a result of running commands in ``this'' crontab.  If  MAILTO  is  defined  (and\nnon-empty),  mail  is sent to the user so named.  If MAILTO is defined but empty (MAILTO=\"\"),\nno mail will be sent.  Otherwise mail is sent to the owner of the crontab.   This  option  is\nuseful  if  you  decide on /usr/bin/mail instead of /usr/lib/sendmail as your mailer when you\ninstall cron -- /usr/bin/mail doesn't do aliasing, and UUCP usually doesn't read its mail.\n\nThe format of a cron command is very much the V7 standard, with a number of upward-compatible\nextensions.  Each line has five time and date fields, followed by a command,  followed  by  a\nnewline  character  ('\\n').   The  system crontab (/etc/crontab) uses the same format, except\nthat the username for the command is specified after the time and date fields and before  the\ncommand.   The  fields  may be separated by spaces or tabs.  The maximum permitted length for\nthe command field is 998 characters.\n\nCommands are executed by cron(8) when the minute, hour, and month of year  fields  match  the\ncurrent  time,  and  when  at  least one of the two day fields (day of month, or day of week)\nmatch the current time (see ``Note''  below).   cron(8)  examines  cron  entries  once  every\nminute.  The time and date fields are:\n\nfield          allowed values\n-----          --------------\nminute         0-59\nhour           0-23\nday of month   0-31\nmonth          0-12 (or names, see below)\nday of week    0-7 (0 or 7 is Sun, or use names)\n\nA field may be an asterisk (*), which always stands for ``first-last''.\n\nRanges  of  numbers are allowed.  Ranges are two numbers separated with a hyphen.  The speci‐\nfied range is inclusive.  For example, 8-11 for an ``hours''  entry  specifies  execution  at\nhours 8, 9, 10 and 11.\n\nLists  are  allowed.   A list is a set of numbers (or ranges) separated by commas.  Examples:\n``1,2,5,9'', ``0-4,8-12''.\n\nStep values can be used in conjunction with ranges.  Following  a  range  with  ``/<number>''\nspecifies skips of the number's value through the range.  For example, ``0-23/2'' can be used\nin  the  hours field to specify command execution every other hour (the alternative in the V7\nstandard is ``0,2,4,6,8,10,12,14,16,18,20,22'').  Steps are also permitted after an asterisk,\nso if you want to say ``every two hours'', just use ``*/2''.\n\nNames can also be used for the ``month'' and ``day of week'' fields.   Use  the  first  three\nletters  of  the particular day or month (case doesn't matter).  Ranges or lists of names are\nnot allowed.\n\nThe ``sixth'' field (the rest of the line) specifies the command to be run.  The entire  com‐\nmand  portion of the line, up to a newline or % character, will be executed by /usr/bin/sh or\nby the shell specified in the SHELL variable of the cronfile.  Percent-signs (%) in the  com‐\nmand,  unless  escaped  with  backslash (\\), will be changed into newline characters, and all\ndata after the first % will be sent to the command as standard input.\n\nNote: The day of a command's execution can be specified by two fields — day of month, and day\nof week.  If both fields are restricted (i.e., aren't *), the command will be run when either\nfield matches the current time.  For example,\n``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the  1st  and  15th  of  each\nmonth,  plus  every Friday.  One can, however, achieve the desired result by adding a test to\nthe command (see the last example in EXAMPLE CRON FILE below).\n\nInstead of the first five fields, one of eight special strings may appear:\n\nstring         meaning\n------         -------\n@reboot        Run once, at startup.\n@yearly        Run once a year, \"0 0 1 1 *\".\n@annually      (same as @yearly)\n@monthly       Run once a month, \"0 0 1 * *\".\n@weekly        Run once a week, \"0 0 * * 0\".\n@daily         Run once a day, \"0 0 * * *\".\n@midnight      (same as @daily)\n@hourly        Run once an hour, \"0 * * * *\".\n\nPlease note that startup, as far as @reboot is concerned, is the time when the cron(8) daemon\nstartup.  In particular, it may be before some system  daemons,  or  other  facilities,  were\nstartup.  This is due to the boot order sequence of the machine.\n\n",
            "subsections": []
        },
        "EXAMPLE CRON FILE": {
            "content": "# use /usr/bin/sh to run commands, no matter what /etc/passwd says\nSHELL=/usr/bin/sh\n# mail any output to `paul', no matter whose crontab this is\nMAILTO=paul\n#\n# run five minutes after midnight, every day\n5 0 * * *       $HOME/bin/daily.job >> $HOME/tmp/out 2>&1\n# run at 2:15pm on the first of every month -- output mailed to paul\n15 14 1 * *     $HOME/bin/monthly\n# run at 10 pm on weekdays, annoy Joe\n0 22 * * 1-5    mail -s \"It's 10pm\" joe%Joe,%%Where are your kids?%\n23 0-23/2 * * * echo \"run 23 minutes after midn, 2am, 4am ..., everyday\"\n5 4 * * sun     echo \"run at 5 after 4 every Sunday\"\n0 */4 1 * mon   echo \"run every 4th hour on the 1st and on every Monday\"\n0 0 */2 * sun   echo \"run at midn on every Sunday that's an uneven date\"\n# Run on every second Saturday of the month\n0 4 8-14 * *    test $(date +\\%u) -eq 6 && echo \"2nd Saturday\"\n# Same thing, efficient too:\n0 4 * * * Sat   d=$(date +e) && test $d -ge 8 -a $d -le 14 && echo \"2nd Saturday\"\n#Execute early the next morning following the first\n#Thursday of each month\n57 2 * * 5 case $(date +d) in 0[2-8]) echo \"After 1st Thursday\"; esac\n\n\nAll  the  above examples run non-interactive programs.  If you wish to run a program that in‐\nteracts with the user's desktop you have to make sure the proper environment variable DISPLAY\nis set.\n\n# Execute a program and run a notification every day at 10:00 am\n0 10 * * *  $HOME/bin/program | DISPLAY=:0 notify-send \"Program run\" \"$(cat)\"\n\n",
            "subsections": []
        },
        "EXAMPLE SYSTEM CRON FILE": {
            "content": "The following lists the content of a regular  system-wide  crontab  file.   Unlike  a  user's\ncrontab, this file has the username field, as used by /etc/crontab.\n\n# /etc/crontab: system-wide crontab\n# Unlike any other crontab you don't have to run the `crontab'\n# command to install the new version when you edit this file\n# and files in /etc/cron.d.  These files also have username fields,\n# that none of the other crontabs do.\n\nSHELL=/bin/sh\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n\n# Example of job definition:\n# .---------------- minute (0 - 59)\n# |  .------------- hour (0 - 23)\n# |  |  .---------- day of month (1 - 31)\n# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...\n# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat\n# |  |  |  |  |\n# m h dom mon dow usercommand\n17 * * * *  root  cd / && run-parts --report /etc/cron.hourly\n25 6 * * *  root  test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )\n47 6 * * 7  root  test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )\n52 6 1 * *  root  test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )\n#\n\nNote  that all the system-wide tasks will run, by default, from 6 am to 7 am.  In the case of\nsystems that are not powered on during that period of time, only the hourly tasks will be ex‐\necuted unless the defaults above are changed.\n\n",
            "subsections": []
        },
        "YET ANOTHER EXAMPLE": {
            "content": "In that example one can see that numbers can be  prepended  some  0,  in  order  to  line  up\ncolumns.\n\n17  * * * *  root  cd / && run-parts --report /etc/cron.hourly\n25 16 * * *  root  test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )\n47 06 * * 7  root  test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )\n52 06 1 * *  root  test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "cron(8), crontab(1)\n",
            "subsections": []
        },
        "EXTENSIONS": {
            "content": "When  specifying  day  of week, both day 0 and day 7 will be considered Sunday.  BSD and AT&T\nseem to disagree about this.\n\nLists and ranges are allowed to co-exist in the same field.  \"1-3,7-9\" would be  rejected  by\nAT&T or BSD cron -- they want to see \"1-3\" or \"7,8,9\" ONLY.\n\nRanges can include \"steps\", so \"1-9/2\" is the same as \"1,3,5,7,9\".\n\nNames of monts or days of the week can be specified by name.\n\nEnvironment  variables  can be set in the crontab.  In BSD or AT&T, the environment handed to\nchild processes is basically the one from /etc/rc.\n\nCommand output is mailed to the crontab owner (BSD can't do this), can be mailed to a  person\nother  than  the  crontab owner (SysV can't do this), or the feature can be turned off and no\nmail will be sent at all (SysV can't do this either).\n\nAll of the `@' commands that can appear in place of the first five fields are extensions.\n",
            "subsections": []
        },
        "LIMITATIONS": {
            "content": "The cron daemon runs with a defined timezone.  It currently does not support  per-user  time‐\nzones.   All  the  tasks:  system's  and user's will be run based on the configured timezone.\nEven if a user specifies the TZ environment variable in his crontab this will affect only the\ncommands executed in the crontab, not the execution of the crontab tasks themselves.  If  one\nwants to specify a particular timezone for crontab tasks, one may check the date in the child\nscript, for example:\n\n# m h  dom mon dow   command\n\nTZ=UTC\n0 * * * * [ \"$(date +\\%R)\" = 00:00 ] && runsomescript\n\nPOSIX  specifies that the day of month and the day of week fields both need to match the cur‐\nrent time if either of them is a *.  However, this implementation only checks  if  the  first\ncharacter  is a *.  This is why \"0 0 */2 * sun\" runs every Sunday that's an uneven date while\nthe POSIX standard would have it run every Sunday and on every uneven date.\n\nThe crontab syntax does not make it possible to define all possible periods one can  imagine.\nFor example, it is not straightforward to define the last weekday of a month.  To have a task\nrun  in a time period that cannot be defined using crontab syntax, the best approach would be\nto have the program itself check the date and time information and continue execution only if\nthe period matches the desired one.\n\nIf the program itself cannot do the checks then a wrapper script would be  required.   Useful\ntools that could be used for date analysis are ncal or calendar For example, to run a program\nthe last Saturday of every month you could use the following wrapper code:\n\n0 4 * * Sat   [ \"$(date +\\%e)\" = \"$(LANG=C ncal | sed -n 's/^Sa .* \\([0-9]\\+\\) *$/\\1/p')\" ] && echo \"Last Saturday\" && programtorun\n\n",
            "subsections": []
        },
        "USING EVAL TO WRAP MISC ENVIRONMENT SETTINGS": {
            "content": "The following tip is kindly provided by 積丹尼 Dan Jacobson:\n\nCONTENTTYPE=\"text/plain; charset=UTF-8\"\nd=eval LANG=zhTW.UTF-8 w3m -dump\n26 22 16 1-12 * $d https://www.ptt.cc/bbs/transgender/index.html\n\nit won't work without the eval. Saying\nd=LANG=zhTW.UTF-8 w3m -dump\nwill get\n/bin/sh: LANG=zhTW.UTF-8: command not found\n\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "cron  requires that each entry in a crontab end in a newline character.  If the last entry in\na crontab is missing a newline (i.e. terminated by EOF), cron will consider the  crontab  (at\nleast partially) broken.  A warning will be written to syslog.\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Paul  Vixie  <paul@vix.com>  is  the author of cron and original creator of this manual page.\nThis page has also been modified for Debian by Steve  Greenland,  Javier  Fernandez-Sanguino,\nChristian Kastner, Christian Pekeler, Georges Khaznadar.\n\n4th Berkeley Distribution                   19 April 2010                                 CRONTAB(5)",
            "subsections": []
        }
    },
    "summary": "crontab - tables for driving cron",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "cron",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/cron/8/json"
        }
    ]
}