Previous: , Up: Crontab Format   [Contents][Index]


2.2.2 Variable Settings

Variable settings modify execution environment for subsequent cron commands. Some variables are internal to micrond and modify its behavior. A variable setting has the form

name = value

where name is the variable name and value is the value to be assigned to it. Notice several important differences from the similar construct in shell. First of all, optional whitespace is allowed on either side of the equals sign. Secondly, the value is assigned verbatim, after removing any trailing and leading whitespace. No expansions or substitutions take place. If you need this kind of functionality, move environment manipulations to a shell script and invoke it from the cron command.

You don’t need to quote value even if it contains embedded whitespace. There are only two cases when quoting becomes necessary: to define an empty variable or to preserve leading or trailing whitespace. Both single and double quotes can be used, the only requirement being that both quotes match. Inside a quoted string, a backslash character can be used to escape a quote character or another backslash. To define an empty variable, use a pair of quotes.

The special construct

name =

unsets the variable name.

Each variable setting applies to all cron commands that follow it, until another setting overwrites it or the end of file is encountered.

The following are built-in variables. They modify the handling of cron commands that follow them, but are not copied to the command environment. Variables prefixed with ‘_JOB_’ affect only the first cron command that appears after them, whereas variables prefixed with ‘_MICRON_’ affect all commands that follow them, until another assignment of the same variable is encountered or the end of the file is reached. A built-in variable can be assigned a default value in the command line using the -v option (see initial value).

Built-in variable: _MICRON_OUTFILE_FACILITY
Built-in variable: _JOB_OUTFILE_FACILITY

The value of this variable is the name of a file. If the variable is set, any output the cronjob produces will be appended to that file.

See Sending output to file.

Built-in variable: _MICRON_SYSLOG_FACILITY
Built-in variable: _JOB_SYSLOG_FACILITY

If this variable is set to a meaningful syslog facility, the cronjob output will be logged to that facility (priority ‘INFO’), instead of mailing it the usual way. See Logging output to syslog.

Allowed values for this variable are auth, authpriv, cron, daemon, ftp, lpr, mail, news, syslog, user, uucp, and local0 through local7.

The value default means to use the default syslog facility (cron), and off or none disables syslog and reverts to mailing the program output as directed by the MAILTO variable (see MAILTO).

Built-in variable: _JOB_SYSLOG_TAG

Sets the syslog tag for the next cron command. The tag is used when logging cronjob output to syslog (see Logging output to syslog), or appending it to a file (see Sending output to file). If not specified, the tag will be constructed as

file:line(prog)

where file and line are the file name and line number of the line where the cron command appeared and prog is the first word of the command.

The global counterpart of this variable, _MICRON_SYSLOG_TAG, is provided for completeness. It is probably of little use, since it sets the same tag for all crontab entries.

Built-in variable: _MICRON_MAXINSTANCES
Built-in variable: _JOB_MAXINSTANCES

An integer value defining how many instances of the same cron job can be running simultaneously. Default is 1, i.e. micrond will refuse to start a job if its previous run has not yet terminated.

Built-in variable: _JOB_MAILTO

This variable temporarily masks the MAILTO environment variable and disables the variables _MICRON_SYSLOG_FACILITY and _MICRON_OUTFILE for the next crontab entry. After that, the previous values are restored. Use it to redirect output of a single crontab entry to a particular email address.

The global version of this variable, _MICRON_MAILTO, is mostly equivalent to the traditional MAILTO variable, except that any existing value of MAILTO is retained in the environment.

See Mailing the cronjob output, for the detailed discussion of how the output is mailed.

See Cronjob Output

Built-in variable: _MICRON_DAY_SEMANTICS
Built-in variable: _JOB_DAY_SEMANTICS

Defines the day semantics. Allowed values are: strict, vixie, and dillon (case-insensitive). See Day Field Semantics.

The following are environment variables that modify the behavior of micrond itself.

Environment: MAILTO

Defines an email address or a comma-delimited list of email addresses. If any of the cron commands that follow this setting produces anything on its standard output or standard error, the output will be collected and mailed to the emails listed in the MAILTO variable. If the variable is undefined, the output will be sent to the owner of the crontab. If MAILTO is set to an empty string, no mail will be sent.

See Mailing the cronjob output, for the detailed discussion of how the output is mailed.

Environment: HOME

Defines the working directory from which the subsequent commands will be run. Defaults to home directory of the user on whose behalf the command is run.

Environment: SHELL

Defines the shell used to start commands. Defaults to ‘/bin/sh’.


Previous: , Up: Crontab Format   [Contents][Index]