Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Prevent windowserver.log from filling with entries System
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.]
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[13,052 views]  

Prevent windowserver.log from filling with entries | 5 comments | Create New Account
Click here to return to the 'Prevent windowserver.log from filling with entries' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Prevent windowserver.log from filling with entries
Authored by: mathieu on Jul 03, '07 08:23:14AM

Isn't it simpler to just symblink the files to /dev/null? Why should the script be executed every hour?



[ Reply to This | # ]
Prevent windowserver.log from filling with entries
Authored by: garythemacguy on Jul 03, '07 10:01:06AM

My windowserver.log and windowserver_last.log files are each less than 100,000 bytes long. And I use command-tab switching all the time.

My Mac is left on over-night (albeit with the HD allowed to spin down and the screen asleep). So I'm going to guess that, as noted by rogb, either the daily or weekly maintenance scripts are keeping these two files under control. (My guess is the weekly one.)

If you turn off (or sleep) your Mac overnight, then far better to use your cron script to run the appropriate "missing" maintenance script at a time when - most days at least - you can expect your Mac to be available.



[ Reply to This | # ]
Prevent bloat ≠ Delete logs!!! when windowserver.log grows too big
Authored by: zahadum on Jul 03, '07 10:52:01AM

wow.

this is a a really bad idea.

talk about throwing out the baby with the bathwater.

the wholesale destruction of log data is NEVER a good idea.

if you are savvy enough to be concerned with logs, then you should have the technical skills to manage them properly: ie write a script that parses out what you dont want (and for those who want to see a system-level reward for this house-keeping effort, this is a good occasion to learn to finally move beyond bash or perl & start learning about functional style programming techniques).

of course it bears repeating that most of the problem here is due to apple's neglect - surprise! ... there is no structured representation for the log files.

apple should have used leopard as the occasion to introduce an XML format for the logs (as well as integration with postgress .... why apple has forfeited the many slick opportunities to leverage webobjects on the desktop is beyond comprehension ... nonetheless, postgress offers the most amount of abstraction
possible for osx infrastructure management short of webobjects itself).

sadly, like most other cool initiatives at apple, xml in osx started off with a flourish but was left t languish (it is used for plists & bundle management etc).

so for log management, as with most other things at apple, the end-user is left holding the bag, having to glue together some ad hoc, low-level work-around ...

which in this case means filtering the log files for extraneous entries.

btw: It is no surprise that apple doesnt provide -

* CoreData for structured log storage
* any automator workflows, or even
* (robust/any!) applescript dictionary for console.app ...

the lack of log manipulation tools in osx - especially for windowserver - makes it easy for apple not to draw attention to how many frickin' hangs! Hangs!! HANGS!!! osx inflicts upon the user.

putting up with the hangs in osx is almost like putting up with the crashes in classic (sys 7.5) .... the constant interruption in work slowly grinds down one's spirit to the point of despair.

---
mailto:osxinfo _at_ yahoo.ca



[ Reply to This | # ]
Prevent windowserver.log from filling with entries
Authored by: blackxacto on Jul 03, '07 10:52:43AM

I could not get the script to compile. But I am no expert at it either. jr

---
You'll never know which way to look, which way to see us.



[ Reply to This | # ]
Prevent windowserver.log from filling with entries
Authored by: osxpounder on Jul 03, '07 11:54:53AM

This happened to me for the first time about a week or two ago.

I was running Cubase LE, doing some heavy sound editing, but also had other apps up from time to time, like Mail [a real pig now, increasingly slow to start or change mailboxes], iChat, Cisco VPN client, and of course TextEdit... I also ran Parallels a few times between sessions, and wondered if Paralells had eaten up my HD space [because it does seem to eat about 2-3GB, temporarily, when running, on the system partition for OSX].

I couldn't spend much time troubleshooting, because of the editing deadline. Once I discovered it was a "windowserver" log file [I think it was "windowserver_last.log"], I nuked that file [realizing I wouldn't know enough to use it to diagnose, and having no place to store its many GB]. After a reboot, all was fine. I don't know why

I haven't even finished reading this hint yet. Just wanted to report my similar experience here in case it illuminates something.



[ Reply to This | # ]