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:
ERRFILE=$HOME/.xsession-errors
# 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" \
"\"$TMPDIR/xsession-$USER\"."
fi
else
errormsg "unable to create X session log/error file; aborting."
fi
# 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"
fi
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.