You can send your cron logs to Loggly by redirecting the standard output and error to logger. Logger will send them to your syslog daemon, which then forward them to Loggly. This can be easier than using Postfix which requires you manage emails. For alternatives, such as sending file logs from cron jobs, or capturing cron syslog events, see the Advanced Options section below.
curl -O https://www.loggly.com/install/configure-linux.sh sudo bash configure-linux.sh -a SUBDOMAIN -u USERNAME
- SUBDOMAIN: your account subdomain that you created when you signed up for Loggly.
- USERNAME: your Loggly username.
You can redirect your cron standard output to syslog using the logger command.
*/5 * * * * COMMAND 2>&1 | /usr/bin/logger -t APPNAME
- COMMAND: insert your own cron command or script
- APPNAME: replace with your own custom app or cron name
For example, this cron job which prints ‘Hello World!’ every 5 minutes:
*/5 * * * * echo 'Hello World!' 2>&1 | /usr/bin/logger -t HelloCron
It creates the following log entry
Apr 28 17:20:01 PSQ110 HelloCron: Hello World!
Search Loggly for events with your chosen appName over the past hour. It may take few minutes to index the event. If if doesn’t work, see the troubleshooting section below.
- Linux Syslog – capture syslog events from the cron executable itself, which describes when crons are run
- Log File Monitoring – If you log to file, you can send these files to Loggly.
- Loggly Libraries Catalog – You can find more options here to send logs to Loggly.
- Wait a few minutes in case indexing needs to catch up.
- Check if you have restarted rsyslog service.
- Run "sudo tcpdump -i lo -A udp and port 514″ to verify UDP events are being sent to localhost.
- You can check your /var/log/mail.log file for any cron jobs failure.
- Search or post your own Cron logs questions in the community forum
When the APM Integrated Experience is enabled, Loggly shares a common navigation and enhanced feature set with the other integrated experiences' products. How you navigate the product and access its features may vary from these instructions. For more information, go to the APM Integrated Experience documentation.
The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.