1.\"/* Copyright 1988,1990,1993,1994 by Paul Vixie 2.\" * All rights reserved 3.\" */ 4.\" 5.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 6.\" Copyright (c) 1997,2000 by Internet Software Consortium, Inc. 7.\" 8.\" Permission to use, copy, modify, and distribute this software for any 9.\" purpose with or without fee is hereby granted, provided that the above 10.\" copyright notice and this permission notice appear in all copies. 11.\" 12.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 13.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 15.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 18.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19.\" 20.\" $OpenBSD: crontab.5,v 1.33 2014/01/30 20:02:42 jmc Exp $ 21.\" 22.Dd $Mdocdate: January 30 2014 $ 23.Dt CRONTAB 5 24.Os 25.Sh NAME 26.Nm crontab 27.Nd tables for driving cron 28.Sh DESCRIPTION 29A 30.Nm 31file contains instructions to the 32.Xr cron 8 33daemon of the general form: 34.Dq at these times on these dates run this command . 35There may be a system 36.Nm 37and each user may have their own 38.Nm . 39Commands in any given 40.Nm 41will be 42executed either as the user who owns the 43.Nm 44or, in the case of the system 45.Nm crontab , 46as the user specified on the command line. 47.Pp 48While a 49.Nm 50is a text file, it is not intended to be directly edited. 51Creation, modification, and removal of a 52.Nm 53should be done using 54.Xr crontab 1 . 55.Pp 56Blank lines, leading spaces, and tabs are ignored. 57Lines whose first non-space character is a pound sign 58.Pq Ql # 59are comments, and are ignored. 60Note that comments are not allowed on the same line as 61.Xr cron 8 62commands, since 63they will be taken to be part of the command. 64Similarly, comments are not 65allowed on the same line as environment variable settings. 66.Pp 67An active line in a 68.Nm 69is either an environment variable setting or a 70.Xr cron 8 71command. 72.Pp 73Environment variable settings create the environment 74any command in the 75.Nm 76is run in. 77An environment variable setting is of the form: 78.Pp 79.Dl name = value 80.Pp 81The spaces around the equal sign 82.Pq Ql = 83are optional, and any subsequent non-leading spaces in 84.Ar value 85will be part of the value assigned to 86.Ar name . 87The 88.Ar value 89string may be placed in quotes 90.Pq single or double , but matching 91to preserve leading or trailing blanks. 92.Pp 93Lines in the system 94.Nm 95have six fixed fields plus a command, in the form: 96.Bd -ragged -offset indent 97.Ar minute 98.Ar hour 99.Ar day-of-month 100.Ar month 101.Ar day-of-week 102.Ar user 103.Ar command 104.Ed 105.Pp 106While lines in a user 107.Nm 108have five fixed fields plus a command, in the form: 109.Bd -ragged -offset indent 110.Ar minute 111.Ar hour 112.Ar day-of-month 113.Ar month 114.Ar day-of-week 115.Ar command 116.Ed 117.Pp 118Fields are separated by blanks or tabs. 119The command may be one or more fields long. 120The allowed values for the fields are: 121.Bl -column "day-of-month" "allowed values" -offset indent 122.It Sy field Ta Sy allowed values 123.It Ar minute Ta * or 0\(en59 124.It Ar hour Ta * or 0\(en23 125.It Ar day-of-month Ta * or 1\(en31 126.It Ar month Ta * or 1\(en12 or a name (see below) 127.It Ar day-of-week Ta * or 0\(en7 or a name (0 or 7 is Sunday) 128.It Ar user Ta a valid username 129.It Ar command Ta text 130.El 131.Pp 132Lists are allowed. 133A list is a set of numbers (or ranges) separated by commas. 134For example, 135.Dq 1,2,5,9 136or 137.Dq 0\(en4,8\(en12 . 138.Pp 139Ranges of numbers are allowed. 140Ranges are two numbers separated with a hyphen. 141The specified range is inclusive. 142For example, 1438\(en11 for an 144.Ar hour 145entry specifies execution at hours 8, 9, 10 and 11. 146.Pp 147Step values can be used in conjunction with ranges. 148Following a range with 149.No / Ns Ar number 150specifies skips of 151.Ar number 152through the range. 153For example, 154.Dq 0\(en23/2 155can be used in the 156.Ar hour 157field to specify command execution every other hour. 158Steps are also permitted after an asterisk, so to say 159.Dq every two hours , 160just use 161.Dq */2 . 162.Pp 163An asterisk 164.Pq Ql * 165is short form for a range of all allowed values. 166.Pp 167Names can be used in the 168.Ar month 169and 170.Ar day-of-week 171fields. 172Use the first three letters of the particular 173day or month (case doesn't matter). 174Ranges or lists of names are not allowed. 175.Pp 176The 177.Ar command 178field (the rest of the line) is the command to be 179run. 180The entire command portion of the line, up to a newline or % 181character, will be executed by 182.Pa /bin/sh 183or by the shell 184specified in the 185.Ev SHELL 186variable of the 187.Nm crontab . 188Percent signs 189.Pq Ql % 190in the command, unless escaped with a backslash 191.Pq Ql \e , 192will be changed into newline characters, and all data 193after the first 194.Ql % 195will be sent to the command as standard input. 196.Pp 197Commands are executed by 198.Xr cron 8 199when the 200.Ar minute , 201.Ar hour , 202and 203.Ar month 204fields match the current time, 205.Em and 206when at least one of the two day fields 207.Po Ar day-of-month 208or 209.Ar day-of-week Pc , 210match the current time. 211.Pp 212Note: The day of a command's execution can be specified by two 213fields \(em 214.Ar day-of-month 215and 216.Ar day-of-week . 217If both fields are restricted (i.e. aren't *), 218the command will be run when 219.Em either 220field matches the current time. 221For example, 222.Pp 223.Dl 30 4 1,15 * 5 224.Pp 225would cause a command to be run at 4:30 am on the 1st and 15th of each 226month, plus every Friday. 227.Pp 228Instead of the first five fields, one of eight special strings may appear: 229.Bl -column "@midnight" "meaning" -offset indent 230.It Sy string Ta Sy meaning 231.It @reboot Ta Run once, at startup. 232.It @yearly Ta Run every January 1 (0 0 1 1 *). 233.It @annually Ta The same as @yearly. 234.It @monthly Ta Run the first day of every month (0 0 1 * *). 235.It @weekly Ta Run every Sunday (0 0 * * 0). 236.It @daily Ta Run every midnight (0 0 * * *). 237.It @midnight Ta The same as @daily. 238.It @hourly Ta Run every hour, on the hour (0 * * * *). 239.El 240.Sh ENVIRONMENT 241.Bl -tag -width "LOGNAMEXXX" 242.It Ev HOME 243Set from the user's 244.Pa /etc/passwd 245entry. 246May be overridden by settings in the 247.Nm . 248.It Ev LOGNAME 249Set from the user's 250.Pa /etc/passwd 251entry. 252May not be overridden by settings in the 253.Nm . 254.It Ev MAILTO 255If 256.Ev MAILTO 257is defined and non-empty, 258mail is sent to the user so named. 259If 260.Ev MAILTO 261is defined but empty 262.Pq Ev MAILTO = Qq , 263no mail will be sent. 264Otherwise mail is sent to the owner of the 265.Nm . 266This is useful for pseudo-users that lack an alias 267that would otherwise redirect the mail to a real person. 268.It Ev SHELL 269Set to 270.Pa /bin/sh . 271May be overridden by settings in the 272.Nm . 273.It Ev USER 274Set from the user's 275.Pa /etc/passwd 276entry. 277May not be overridden by settings in the 278.Nm . 279.El 280.Sh FILES 281.Bl -tag -width "/var/cron/tabs/<user>XXX" -compact 282.It Pa /etc/crontab 283System crontab. 284.It Pa /var/cron/tabs/ Ns Aq Ar user 285User crontab. 286.El 287.Sh EXAMPLES 288.Bd -literal 289# use /bin/sh to run commands, no matter what /etc/passwd says 290SHELL=/bin/sh 291# mail any output to `paul', no matter whose crontab this is 292MAILTO=paul 293# 294# run five minutes after midnight, every day 2955 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1 296# run at 2:15pm on the first of every month -- output mailed to paul 29715 14 1 * * $HOME/bin/monthly 298# run at 10 pm on weekdays, annoy Joe 2990 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?% 30023 0-23/2 * * * echo "run 23 minutes after midn, 2am, 4am ..., everyday" 3015 4 * * sun echo "run at 5 after 4 every sunday" 302.Ed 303.Sh SEE ALSO 304.Xr crontab 1 , 305.Xr cron 8 306.Sh STANDARDS 307The 308.Nm 309file format is compliant with the 310.St -p1003.1-2008 311specification. 312The behaviours described below are all extensions to that standard: 313.Bl -dash 314.It 315The 316.Ar day-of-week 317field may use 7 to represent Sunday. 318.It 319Ranges may include 320.Dq steps . 321.It 322Months or days of the week can be specified by name. 323.It 324Environment variables can be set in a crontab. 325.It 326Command output can be mailed to a person other than the crontab 327owner, or the feature can be turned off and no mail will be sent 328at all. 329.It 330All of the 331.Ql @ 332commands that can appear in place of the first five fields. 333.El 334.Sh AUTHORS 335.Nm 336was written by 337.An Paul Vixie Aq Mt vixie@isc.org . 338