Prevent windowserver.log from filling with entries

Jul 03, '07 07:30:01AM

Contributed by: JWiegley

OS X has a habit of writing messages to /var » log » windowserver.log every time you press Command-Tab. This has been discussed before on the macosxhints.com forums. There have also been cases reported of people running out of disk space because windowserver.log starts growing without bounds (although this has never happened to me personally). The log entries look like this (date and time removed for narrower display):

 [139] Hot key operating mode is now all but UA disabled
 [139] "Dock" (0x6a07) set hot key operating mode to normal
 [139] Hot key operating mode is now normal
Anyway, both of these issues can be solved very simply: by turning the windowserver.log file into a /dev/null device. Then all logged messages will simply be dropped, and no disk activity or consumption will occur at all.

The script is very simple, and should be run as root (using sudo) from cron at hourly intervals:

#!/bin/bash

# This script must be run as root.

# Change /var/log/windowserver.log so it's a /dev/null device, since
# OS/X 10.4 writes out bogus messages every time Cmd-Tab is used.

if [[ ! -c /var/log/windowserver.log ]]; then
    cd /var/log
    rm -f windowserver.log windowserver_last.log

    mknod windowserver.log c 3 2
    chown root:admin windowserver.log
    chmod 640 windowserver.log
fi
[robg adds: I haven't tested this one, but I can confirm the messages definitely show up for me -- the lines above are from my log file. As an alternative solution, I think it might be a bit simpler to just rm the log files every so often via a cron task. As the two files on my machine are using only 120KB of drive space, though, I'm not going to worry about it. Making sure the daily, weekly, and monthly maintenance tasks run regularly should also prevent the log files from growing out of control -- the freeware MacJanitor (and probably a dozen or so other apps) can help with that task.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20070701021844725