Previous: , Up: Cronjob Output   [Contents][Index]


2.3.3 Sending output to file

To redirect cronjob output to a file, use the _MICRON_OUTFILE or _JOB_OUTFILE built-in variables. The value of these variables is the name of file to append the output to. For example, to redirect output of all cronjobs in a crontab to file /var/log/cronout, place the following at the beginning of the crontab:

_MICRON_OUTFILE = /var/log/cronout

For example, when running micrond in a docker container, you can redirect the output of all cronjobs to the container log as follows:

_MICRON_OUTFILE = /proc/1/fd/1

The _JOB_OUTFILE variable affects only the cronjob that follows it.

Output from each job is appended to the output file in a single chunk, which appears between the following two delimiter lines:

ts_start: tag output begins

and

ts_end: tag output ends

where ts_start and ts_end are job start and termination timestamps in ISO 8601 format, and tag is the cronjob tag, formatted as described in cronjob tag. If the _SYSLOG_TAG variable is defined, its value will be used instead.

For example:

2021-10-23T03:00:00: /etc/cron.d/backup:16(daily_backup) output begins
.
.
.
2021-10-23T03:07:15: /etc/cron.d/backup:16(daily_backup) output ends