Code: A very simple way to persist the logs of tasks run via crontab is to pipe their stdout
and stderr
into /usr/bin/logger
, which merges them into the syslog. This reuses the existing logging infrastructure already present on most UNIX-y machines, including standard log rotation. Best suited for small amounts of lines.
<some-command> 2>&1 | /usr/bin/logger -t <tag>