1 CRONTAB(1)                       User Commands                      CRONTAB(1)
   2 
   3 
   4 
   5 NAME
   6        crontab - user crontab file
   7 
   8 SYNOPSIS
   9        /usr/bin/crontab [-u username] [filename]
  10 
  11 
  12        /usr/bin/crontab { -e | -l | -r } [username]
  13 
  14 
  15        /usr/bin/crontab -u username { -e | -l | -r }
  16 
  17 
  18        /usr/xpg4/bin/crontab [filename]
  19 
  20 
  21        /usr/xpg4/bin/crontab { -e | -l | -r } [username]
  22 
  23 
  24        /usr/xpg4/bin/crontab -u username { -e | -l | -r }
  25 
  26 
  27        /usr/xpg6/bin/crontab [filename]
  28 
  29 
  30        /usr/xpg6/bin/crontab { -e | -l | -r } [username]
  31 
  32 
  33        /usr/xpg6/bin/crontab -u username { -e | -l | -r }
  34 
  35 
  36 DESCRIPTION
  37        The crontab utility manages a user's access with cron (see cron(1M)) by
  38        copying, creating, listing, and removing crontab files. If invoked
  39        without options, crontab copies the specified file, or the standard
  40        input if no file is specified, into a directory that holds all users'
  41        crontabs.
  42 
  43 
  44        If crontab is invoked with filename, this overwrites an existing
  45        crontab entry for the user that invokes it, or for the user specified
  46        with the -u option.
  47 
  48    crontab Access Control
  49        Users: Access to crontab is allowed:
  50 
  51            o      if the user's name appears in /etc/cron.d/cron.allow.
  52 
  53            o      if /etc/cron.d/cron.allow does not exist and the user's name
  54                   is not in /etc/cron.d/cron.deny.
  55 
  56 
  57        Users: Access to crontab is denied:
  58 
  59            o      if /etc/cron.d/cron.allow exists and the user's name is not
  60                   in it.
  61 
  62            o      if /etc/cron.d/cron.allow does not exist and user's name is
  63                   in /etc/cron.d/cron.deny.
  64 
  65            o      if neither file exists, only a user with the
  66                   solaris.jobs.user authorization is allowed to submit a job.
  67 
  68            o      if Auditing is enabled, the user's shell is not audited and
  69                   the user is not the crontab owner. This can occur if the
  70                   user logs in by way of a program, such as some versions of
  71                   SSH, which does not set audit parameters.
  72 
  73 
  74        The rules for allow and deny apply to root only if the allow/deny files
  75        exist.
  76 
  77 
  78        The allow/deny files consist of one user name per line.
  79 
  80    crontab Entry Format
  81        A crontab file consists of lines of six fields each. The fields are
  82        separated by spaces or tabs. The first five are integer patterns that
  83        specify the following:
  84 
  85          minute (0-59),
  86          hour (0-23),
  87          day of the month (1-31),
  88          month of the year (1-12),
  89          day of the week (0-6 with 0=Sunday).
  90 
  91 
  92 
  93 
  94        Each of these patterns can be either an asterisk (meaning all legal
  95        values) or a list of elements separated by commas. An element is either
  96        a number or two numbers separated by a hyphen (meaning an inclusive
  97        range).
  98 
  99        A range or asterisk can optionally be followed by a step value as
 100        /<number>. For example, 2-59/3 can be used in the minutes field to
 101        specify every three minutes starting at 2 past the hour, or */2 in the
 102        hours field means every two hours.
 103 
 104        Time specified here is interpreted in the currently active timezone. At
 105        the top of the crontab file this is the timezone which is set system-
 106        wide in /etc/default/init. A user can add a line such as:
 107 
 108          TZ=timezone
 109 
 110 
 111 
 112 
 113        ...and all subsequent entries will be interpreted using that timezone,
 114        until a new TZ=timezone line is encountered. The specification of days
 115        can be made by two fields (day of the month and day of the week). Both
 116        are adhered to if specified as a list of elements. See EXAMPLES.
 117 
 118 
 119        The sixth field of a line in a crontab file is a string that is
 120        executed by the shell at the specified times. A percent character in
 121        this field (unless escaped by \) is translated to a NEWLINE character.
 122 
 123 
 124        Only the first line (up to a `%' or end of line) of the command field
 125        is executed by the shell. Other lines are made available to the command
 126        as standard input. Any blank line or line beginning with a `#' is a
 127        comment and is ignored.
 128 
 129 
 130        The shell is invoked from your $HOME directory. As with $TZ, both
 131        $SHELL and $HOME can be set by having a line such as:
 132 
 133          SHELL=/usr/bin/someshell
 134 
 135 
 136 
 137 
 138        ...or:
 139 
 140          HOME=somedirectory
 141 
 142 
 143 
 144 
 145        ...which will take precedence for all the remaining entries in the
 146        crontab or until there is another HOME or SHELL entry. It is invoked
 147        with an arg0 of the basename of the $SHELL that is currently in effect.
 148        A user who wants to have his .profile or equivalent file executed must
 149        explicitly do so in the crontab file. cron supplies a default
 150        environment for every shell, defining HOME, LOGNAME, SHELL, TZ, and
 151        PATH. The default PATH for user cron jobs is /usr/bin; while root cron
 152        jobs default to /usr/sbin:/usr/bin. The default PATH can be set in
 153        /etc/default/cron (see cron(1M)). The TZ, HOME, and SHELL environment
 154        variables are set to match those that are in effect in the crontab file
 155        at the time.
 156 
 157 
 158        If you do not redirect the standard output and standard error of your
 159        commands, any generated output or errors are mailed to you.
 160 
 161    crontab Environment Variables
 162        The following variables are supported:
 163 
 164        HOME
 165 
 166            Allows the user to choose and alternative directory for cron to
 167            change directory to prior to running the command. For example:
 168 
 169              HOME=/var/tmp
 170 
 171 
 172 
 173 
 174        SHELL
 175 
 176            The name of the shell to use to run subsequent commands. For
 177            example:
 178 
 179              SHELL=/usr/bin/ksh
 180 
 181 
 182 
 183 
 184        TZ
 185 
 186            Allows the user to choose the timezone in which the cron entries
 187            are run.  This effects both the environment of the command that is
 188            run and the timing of the entry. For example, to have your entries
 189            run using the timezone for Iceland, use:
 190 
 191              TZ=Iceland
 192 
 193 
 194 
 195 
 196 
 197        Each of these variables affects all of the lines that follow it in the
 198        crontab file, until it is reset by a subsequent line resetting that
 199        variable. Hence, it is possible to have multiple timezones supported
 200        within a single crontab file.
 201 
 202 
 203        The lines that are not setting these environment variables are  the
 204        same as crontab entries that conform to the UNIX standard and are
 205        described elsewhere in this man page.
 206 
 207    Setting cron Jobs Across Timezones
 208        The default timezone of the cron daemon sets the system-wide timezone
 209        for cron entries. This, in turn, is by set by default system-wide using
 210        /etc/default/init.
 211 
 212 
 213        If some form of daylight savings or summer/winter time is in effect,
 214        then jobs scheduled during the switchover period could be executed
 215        once, twice, or not at all.
 216 
 217 OPTIONS
 218        The following options are supported:
 219 
 220        -e
 221              Edits a copy of the current user's crontab file, or creates an
 222              empty file to edit if crontab does not exist. When editing is
 223              complete, the file is installed as the user's crontab file.
 224 
 225              The environment variable EDITOR determines which editor is
 226              invoked with the -e option. All crontab jobs should be submitted
 227              using crontab. Do not add jobs by just editing the crontab file,
 228              because cron is not aware of changes made this way.
 229 
 230              If all lines in the crontab file are deleted, the old crontab
 231              file is restored. The correct way to delete all lines is to
 232              remove the crontab file using the -r option.
 233 
 234              If username is specified, the specified user's crontab file is
 235              edited, rather than the current user's crontab file. This can
 236              only be done by root or by a user with the solaris.jobs.admin
 237              authorization.
 238 
 239 
 240        -l
 241              Lists the crontab file for the invoking user. Only root or a user
 242              with the solaris.jobs.admin authorization can specify a username
 243              following the -l option to list the crontab file of the specified
 244              user.
 245 
 246 
 247        -r
 248              Removes a user's crontab from the crontab directory. Only root or
 249              a user with the solaris.jobs.admin authorization can specify a
 250              username following the -r option to remove the crontab file of
 251              the specified user.
 252 
 253 
 254        -u username
 255              Specifies the name of the user whose crontab is to be replaced,
 256              viewed or modified. This can only be done by root or by a user
 257              with the solaris.jobs.admin authorization.
 258 
 259 
 260 
 261 EXAMPLES
 262        Example 1 Cleaning up Core Files
 263 
 264 
 265        This example cleans up core files every weekday morning at 3:15 am:
 266 
 267 
 268          15 3 * * 1-5 find $HOME -namecore 2>/dev/null | xargs rm -f
 269 
 270 
 271 
 272        Example 2 Mailing a Birthday Greeting
 273 
 274 
 275        This example mails a birthday greeting:
 276 
 277 
 278          0 12 14 2 * mailx john%Happy Birthday!%Time for lunch.
 279 
 280 
 281 
 282        Example 3 Specifying Days of the Month and Week
 283 
 284 
 285        This example runs a command on the first and fifteenth of each month,
 286        as well as on every Monday:
 287 
 288 
 289          0 0 1,15 * 1
 290 
 291 
 292 
 293 
 294        To specify days by only one field, the other field should be set to *.
 295        For example:
 296 
 297 
 298          0 0 * * 1
 299 
 300 
 301 
 302 
 303        would run a command only on Mondays.
 304 
 305 
 306        Example 4 Using step values:
 307 
 308 
 309        This example runs a job every hour during the night and every 3 hours
 310        during working hours.
 311 
 312 
 313          0 8-18/3,19-7 * * *
 314 
 315 
 316 
 317        and to run a job every 2 minutes, use:
 318 
 319 
 320          */2 * * * *
 321 
 322 
 323 
 324        Example 5 Using Environment Variables
 325 
 326 
 327        The following entries take advantage of crontab support for certain
 328        environment variables.
 329 
 330 
 331          TZ=GMT
 332          HOME=/local/home/user
 333          SHELL=/usr/bin/ksh
 334          0 0 * * * echo $(date) >     midnight.GMT
 335          TZ=PST
 336          0 0 * * * echo $(date) >     midnight.PST
 337          TZ=EST
 338          HOME=/local/home/myuser
 339          SHELL=/bin/csh
 340 
 341 
 342 
 343 
 344        The preceding entries allow two jobs to run. The first one would run at
 345        midnight in the GMT timezone and the second would run at midnight in
 346        the PST timezone. Both would be run in the directory /local/home/user
 347        using the Korn shell. The file concludes with TZ, HOME, and SHELL
 348        entries that return those variable to their default values.
 349 
 350 
 351 ENVIRONMENT VARIABLES
 352        See environ(5) for descriptions of the following environment variables
 353        that affect the execution of crontab: LANG, LC_ALL, LC_CTYPE,
 354        LC_MESSAGES, and NLSPATH.
 355 
 356    /usr/bin/crontab
 357        EDITOR
 358                  Determine the editor to be invoked when the -e option is
 359                  specified. This is overridden by the VISUAL environmental
 360                  variable. The default editor is vi(1).
 361 
 362 
 363        PATH
 364                  The PATH in crontab's environment specifies the search path
 365                  used to find the editor.
 366 
 367 
 368        VISUAL
 369                  Determine the visual editor to be invoked when the -e option
 370                  is specified. If VISUAL is not specified, then the
 371                  environment variable EDITOR is used. If that is not set, the
 372                  default is vi(1).
 373 
 374 
 375    /usr/xpg4/bin/crontab
 376        EDITOR
 377                  Determine the editor to be invoked when the -e option is
 378                  specified. The default editor is /usr/xpg4/bin/vi.
 379 
 380 
 381    /usr/xpg6/bin/crontab
 382        EDITOR
 383                  Determine the editor to be invoked when the -e option is
 384                  specified. The default editor is /usr/xpg6/bin/vi.
 385 
 386 
 387 EXIT STATUS
 388        The following exit values are returned:
 389 
 390        0
 391              Successful completion.
 392 
 393 
 394        >0
 395              An error occurred.
 396 
 397 
 398 FILES
 399        /etc/cron.d
 400                                    main cron directory
 401 
 402 
 403        /etc/cron.d/cron.allow
 404                                    list of allowed users
 405 
 406 
 407        /etc/default/cron
 408                                    contains cron default settings
 409 
 410 
 411        /etc/cron.d/cron.deny
 412                                    list of denied users
 413 
 414 
 415        /var/cron/log
 416                                    accounting information
 417 
 418 
 419        /var/spool/cron/crontabs
 420                                    spool area for crontab
 421 
 422 
 423 ATTRIBUTES
 424        See attributes(5) for descriptions of the following attributes:
 425 
 426    /usr/bin/crontab
 427 
 428        +--------------------+-----------------+
 429        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 430        +--------------------+-----------------+
 431        |Interface Stability | Standard        |
 432        +--------------------+-----------------+
 433 
 434    /usr/xpg4/bin/crontab
 435 
 436        +--------------------+-----------------+
 437        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 438        +--------------------+-----------------+
 439        |Interface Stability | Standard        |
 440        +--------------------+-----------------+
 441 
 442    /usr/xpg6/bin/crontab
 443 
 444        +--------------------+-----------------+
 445        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 446        +--------------------+-----------------+
 447        |Interface Stability | Standard        |
 448        +--------------------+-----------------+
 449 
 450 SEE ALSO
 451        atq(1), atrm(1), auths(1), ed(1), sh(1), vi(1), cron(1M), su(1M),
 452        auth_attr(4), attributes(5), environ(5), standards(5)
 453 
 454 NOTES
 455        If you inadvertently enter the crontab command with no arguments, do
 456        not attempt to get out with Control-d. This removes all entries in your
 457        crontab file. Instead, exit with Control-c.
 458 
 459 
 460        When updating cron, check first for existing crontab entries that can
 461        be scheduled close to the time of the update. Such entries can be lost
 462        if the update process completes after the scheduled event. This can
 463        happen because, when cron is notified by crontab to update the internal
 464        view of a user's crontab file, it first removes the user's existing
 465        internal crontab and any internal scheduled events. Then it reads the
 466        new crontab file and rebuilds the internal crontab and events. This
 467        last step takes time, especially with a large crontab file, and can
 468        complete after an existing crontab entry is scheduled to run if it is
 469        scheduled too close to the update. To be safe, start a new job at least
 470        60 seconds after the current date and time.
 471 
 472 
 473        If an authorized user other than root modifies another user's crontab
 474        file, the resulting behavior can be unpredictable. Instead, the
 475        authorized user should first use su(1M) to become superuser to the
 476        other user's login before making any changes to the crontab file.
 477 
 478 
 479        Care should be taken when adding TZ, SHELL and HOME variables to the
 480        crontab  file when the crontab file could be shared with applications
 481        that do not expect those variables to be changed from the default.
 482        Resetting the values to their defaults at the bottom of the file will
 483        minimize the risk of problems.
 484 
 485 
 486 
 487                                 August 20, 2020                     CRONTAB(1)