Archive for October 4th, 2012

How to enable cron log separately in cron.log in Debian GNU / Linux

Thursday, October 4th, 2012

Default logging mechanism in and rest of its forks Ubuntu, Xubuntu whatever is done that there is no separate logging for cron daemon (/usr/sbin/cron). Instead all output messages from cron service gets logged in /var/log/auth.log

I don’t like this and since I ever remember using Linux I always liked it whether cron logs its activities in /var/log/cron.log.

Hence on each and every new Desktop or Server install, one of my first things is to set crond log msg separately in /var/log/cron.log.

In older Debians syslog, was used whether in Debian Squeeze, (Wheezy) and onwards releases rsyslog is used.

On hosts depending on syslogd or rsyslogd to manage logs, to enable cron.log just uncomment in either /etc/syslog.conf or /etc/rsyslog.conf:


# cron.* /var/log/cron.log


cron.* /var/log/cron.log

Create cron.log


linux:~# touch /var/log/cron.log

And restart syslogd / rsyslogd and cron


linux:~# /etc/init.d/rsyslogd restart
Stopping enhanced syslogd: rsyslogd.
Starting enhanced syslogd: rsyslogd.
linux:~# /etc/init.d/cron restart
Restarting periodic command scheduler: cron.
....

Check cron.log to see it logs fine:


linux:~# tail -n 5 /var/log/cron.log
Oct 4 16:31:27 pcfreak /usr/sbin/cron[32413]: (CRON) STARTUP (fork ok)
Oct 4 16:31:27 pcfreak /usr/sbin/cron[32413]: (CRON) INFO
(Skipping @reboot jobs -- not system startup)
Oct 4 16:32:35 pcfreak /usr/sbin/cron[32468]: (CRON) INFO
(pidfile fd = 3)
Oct 4 16:32:35 pcfreak /usr/sbin/cron[32469]: (CRON) STARTUP
(fork ok)
Oct 4 16:32:35 pcfreak /usr/sbin/cron[32469]: (CRON) INFO
(Skipping @reboot jobs -- not system startup)

Allow Directory Listing in Apache Webserver / Get around Directory index forbidden by Options directive

Thursday, October 4th, 2012

I have configured Apache VirtualHost, inside the VirtualHost hosted domain, it is supposed to be a directory, where Directory Listing has to be allowed. My VirtualHost configuration looks like so:


NameVirtualHost *

ServerAdmin my-email@domain-name.com
ServerName www.pc-freak.net
ServerAlias www.domain-name.com domain-name.com
DocumentRoot /var/www
DirectoryIndex index.html index.htm index.php index.html.var

Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all


Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined

I have a directory (/var/www/directory), there I store various files and I prefer this directory to be enabled to support Directory listing. I have the whole situation on Debian Linux. By default in Debian Apache is configured to disable directory listing for subdirectories to both default host and Virtualhosts

In order to enable /var/www/directory, accessed inside browser via web address http://wwww.domain-name.com/directory/ I had to add inside my Virtualhost /etc/apache2/sites-available/domain-name.com following Apache directive:



AddDefaultCharset UTF-8
Options FollowSymLinks Indexes
AllowOverride All

As you can see I included also AddDefaultCharset UTF-8, because inside /directory I have files in cyrillic and, if I don’t explicitly set the encoding to UTF-8, the htmls are improperly shown in browsers.

The exact directive that enables directory listing in Apache is:


Options Indexes

Setting Indexes to -Indexes disables directory listing, e.g.



Options -Indexes

BTW if you need to make certain directory accessible for default set Apache Options (permissions) should be set in /etc/apache2/apache2.conf



Options Indexes
...

This will set Apache directory permissions for all Virtualhost, useful if all virtualhosts share common ServerRoot and the directory has to be accessible via all vhosts.
Well that’s all Cheers 😉