Tag Archives: log

Where is the cron / crontab log? / How to enable the Cron Log?

1. modify rsyslog config: open /etc/rsyslog.d/50-default.conf,remove # before cron.*

pico /etc/rsyslog.d/50-default.conf
Code language: JavaScript (javascript)
[quote] # Default rules for rsyslog. # # For more information see rsyslog.conf(5) and /etc/rsyslog.conf # # First some standard log files. Log by facility. # auth,authpriv.* /var/log/auth.log *.*;auth,authpriv.none -/var/log/syslog cron.* /var/log/cron.log #daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log #lpr.* -/var/log/lpr.log mail.* -/var/log/mail.log #user.* -/var/log/user.log
Code language: PHP (php)

2. chown syslog:admin cron.log

3. restart rsyslog service: sudo service rsyslog restart

sudo service rsyslog restart

4. restart cron service: service cron restart

service cron restart

Now you can check cron log from file cat /var/log/cron.log

How to configure remote log servers with rsyslog?

Rsyslog is an open-source software utility used on UNIX and Unix-like computer systems for forwarding log messages in an IPnetwork. It implements the basic syslog protocol, extends it with content-based filtering, rich filtering capabilities, queued operations to handle offline outputs,[2] support for different module outputs,[3] flexible configuration options and adds features such as using TCP for transport.


pico /etc/rsyslog.conf


# provides UDP syslog reception module(load="imudp") input(type="imudp" port="514")
Code language: PHP (php)


# # Include all config files in /etc/rsyslog.d/ # $IncludeConfig /etc/rsyslog.d/*.conf if $fromhost-ip startswith '' then /var/log/switch-10-20-26-5.log if $fromhost-ip startswith '' then /var/log/switch-10-20-6-12.log if $fromhost-ip startswith '10.20.' then /var/log/switches.log
Code language: PHP (php)


/etc/init.d/rsyslog restart

Configure the remote switch maybe (like cisco sg300 or cisco 2960 or other)
with log server (the IP of your Linux machine) UDP port 514 Facility Local 7 Description if you like and minimum Severity Notice
If you want to access the logs with apache

chmod -R go+rX /var/log/
Code language: JavaScript (javascript)

Here is a simple php script for apache /var/www/html/log.php

<?php $output = shell_exec('tac /var/log/switches.log'); echo "<pre>$output</pre>"; ?>
Code language: HTML, XML (xml)