Daylight Savings Time and Unix Cron

Until recently I was of the opinion that, in Ireland, when the clocks change in Spring and Autumn to account for Daylight Savings Time, they always do so at 2am. Having never given it too much thought over the years, I was surprised to find out last weekend that the time they actually change differs depending on whether the clocks are going forward (Spring) or backward (Autumn).

In Ireland, the clocks go forward one hour at 1am (in Spring) but when they go back again in Autumn, they actually do so at 2am. You can confirm this for yourself on the Greenwich Meantime site for Ireland.

There is an important lesson in this too for administrators of the Unix operating system. Never schedule an import cron task between the hours of 1:00am and 2:00am because if you do, it will not run on the weekend when DST comes into effect and it may be run twice on the weekend where DST ends.

Apache Log File Rotation on Solaris

Here are some quick commands to configure daily rotation of the two main Apache logging files, on a Solaris system that uses a nightly cron task to execute the logadm utility (this is enabled by default on a clean installation of Solaris).

Purge any existing entries

To make nice clean start, you may wish to remove any existing log rotation entries.

# logadm -r /log/apache/access_log
# logadm -r /log/apache/error_log

Commit new log rotation settings

Our requirements were that the log files in question be rotated each day, no matter what size they are, and that the resultant file be compressed and named after the current date.

logadm -c -p 1d -t '$file-%Y-%m-%d' -z 0 -w /log/apache/access_log
logadm -c -p 1d -t '$file-%Y-%m-%d' -z 0 -w /log/apache/error_log

The -c indicates that the log files should copied and truncated rather than renamed. The -w parameter ensures that all of the settings specified in the command be written to the central log rotation configuration file in /etc/logadm.conf