Bootstrap FreeKB - Linux Files - cron log
Linux Files - cron log

Updated:   |  Linux Files articles

The system logger daemon is used to determine where cron logs events. Refer to Linux Fundamentals - Understanding syslog (system log) daemon to determine the system logger deamon your system is using (syslogd, rsyslogd, syslog-ng). Let's say your system is using rsyslogd. In this scenario, the /etc/rsyslogd.conf should contain the following, so that all cron events are logged to the /var/log/cron file.

cron.*      /var/log/cron

 

Or, you can use redirection to append events to a custom log file. In this example, the stdout that is produced by example.sh will be appended to example.txt. So, if example.sh has echo "Hello World", then example.txt will contain Hello World when example.sh is invoked. 2>&1 is used to output both stdout and stderr to the log file.

* * * * * bash /etc/cron.daily/example.sh >> /var/log/cron/example.txt 2>&1

 

Here is an example of what an event in the cron log would look like.

Dec 13 03:34:01 [localhost] CROND[6441]: (root) CMD (/etc/cron.daily/foo.sh)

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 091084 in the box below so that we can be sure you are a human.