Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I am having an issues with my ~/.xsession-errors file filling up my entire drive (128G) in a couple of days. Infact, once it was in a few hours. I run this machine as a server, so it runs for days with out reboot.

I have read some solutions about how to remove the file via cron, or redirect it to /dev/null. My concern though is that my home is on a SSD and I don't want to waste the drive i/o with a bunch of writes I don't want.

How can I prevent it from writing?? Also, if anyone could explain what this file is, and why it has so many errors, I would appreciate it. Does it have to do with my remote sessions vnc/ssh.

UPDATE: It seems to go up in size every time I remote VNC in using "Desktop Sharing".

share|improve this question

marked as duplicate by Luis Alvarado Sep 24 '13 at 3:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

This can be a useful tool for debugging certain applications but in some cases (and most of KDE is a prime example) you end up with way too much stuff just sitting in there.

Deleting (or otherwise abusing) the file will not be a permanent solution because the sessions are set to recreate this file on login. However you have a few options to deal with it.

For the sadist: break all the things!

You can break that behaviour simply by running sudoedit /etc/X11/Xsession and looking for the section that squawks on about ERRFILE. Obviously make a backup first, but I would say you can comment (prepend each line with a #) or remove all the following code:


# attempt to create an error file; abort if we cannot
if (umask 077 && touch "$ERRFILE") 2> /dev/null && [ -w "$ERRFILE" ] &&
  [ ! -L "$ERRFILE" ]; then
  chmod 600 "$ERRFILE"
elif ERRFILE=$(tempfile 2> /dev/null); then
  if ! ln -sf "$ERRFILE" "${TMPDIR:=/tmp}/xsession-$USER"; then
    message "warning: unable to symlink \"$TMPDIR/xsession-$USER\" to" \
             "\"$ERRFILE\"; look for session log/errors in" \
  errormsg "unable to create X session log/error file; aborting."

# truncate ERRFILE if it is too big to avoid disk usage DoS
if [ "`stat -c%s \"$ERRFILE\"`" -gt 500000 ]; then
  T=`mktemp -p "$HOME"`
  tail -c 500000 "$ERRFILE" > "$T" && mv -f "$T" "$ERRFILE" || rm -f "$T"

exec >>"$ERRFILE" 2>&1

echo "$PROGNAME: X session started for $LOGNAME at $(date)"

For the long-login user: cron

I stay logged into my desktop for weeks at a time and if something blows up, chances are I'll only need the debug for a couple of hours, if at all. So I ran crontab -e and created a line like this:

0 * * * * bash -c ">/.xsession-errors"

That just gives the file an hourly colonic.

For the masochist: fix all the bugs!

You have to remember that .xsession-error output is there to indicate a bug or something behaving in a way that it should not. This is not always true (glares at KDE) but in your case with your VNC client, this may indicate that something is going wrong.

If you have a look at the errors you might be able to change your application settings to avoid the error, or failing that, report the error (along with some of the sample messages) to the author of the software.

If it is just spam (Eg: "connecting to server") report that as a bug to the author too. They're misusing the infrastructure.

share|improve this answer
I commented everything out, but after a reboot, the file is back. – ATLChris Feb 27 '13 at 15:16

There's an easier solution but maybe not so useful for some. Don't use xdm or any other DM. Boot your machine up to the text console, login and startx.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.