Is there any way to completely disable the .xsession-errors file? I have it as a symlink to /tmp so that my laptop hard disk can (hopefully) go to sleep for once, but at least 95% of the stuff in the file (it fills up at about 500k an hour) is...

(nautilus:1618): GLib-GObject-CRITICAL **: g_value_get_object: assertion `G_VALUE_HOLDS_OBJECT (value)' failed

which is total garbage to me. I have tried doing a symlink to /dev/null but that does not work (the resulting link is overwritten), and I also do not want the activity so that hopefully my laptop can go to sleep for once.

I am using Ubuntu 11.04, with no special add-ons to Nautilus.

  • That trick does not work for me, because on startup /etc/X11/Xsession does not check what the symbolic link is pointing to. For me it creates a new .xsession-errors regular file, and has .xsession-errors.old linked to /dev/null. That is not what I want. I want .xsession-errors redirected to /dev/null - permantently unless I explicitly change it myself. – bjem Jan 8 '12 at 4:38
  • Just to clarify @j-johan-edwards. I tested your command and it works fine, I just want it to be permanent. – bjem Jan 8 '12 at 4:43
  • Does 11.04 use GDM or LightDM as its display manager? – detly Jan 8 '12 at 5:41
  • I think mine is GDM, if that is the default. I have not changed it except to get away from the Unity desktop. – bjem Jan 8 '12 at 10:21
  • Yes, my one is GDM. Apparently the path to .xsession-errors is hard coded(?!) into its source code. Is there a good way to run a script after GDM loads to redirect .xsession-errors to /dev/null? – bjem Jan 11 '12 at 2:36

I found an interim solution.

I put a small script in /etc/X11/Xsession.d called 91redirect-xsession-errors that does the job for now, but if you want to have your own custom symlink for .xession-errors it does not work for that (I tried and it did not output any data).


# Redirect $HOME/.xsession-errors to /dev/null.
# BJEM 11 January 2012


# This does not seem to work for a regular file,
# i.e. if you want to symlink $HOME/.xsession-errors
# to another file.  I do not know why.

# Creates target file if it does not exist.

# Link .xsession-errors file to the desired target
# no matter what.

# Test case.
#gedit &

##### END OF FILE #####

It's a bit 'rough and ready' but it does the job for me. Note that this is the only file that has been altered.

  • Unfortunately I didn't notice @earlonrails answer. /etc/X11/Xsession wil create the file in /tmp if it's a symbolic link so this method is useless. – int_ua Jul 5 '19 at 19:35

There is a file called /etc/X11/Xsession. Which will create the symlink to a tmp file. IE. Starts on line number 61


# 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."

You can cp this Xsession file to Xsession.bak. Then go a head and point your ERRFILE to /dev/null IE. Line 83

exec >> /dev/null 2>&1
  • 1
    Thank you! I wish I'd noticed this answer earlier. I'll award you 200 reputation. I've made a patch that checks for environment variable $NOXSESSIONERRORS paste.ubuntu.com/p/TFxZ344k2p this way we can hope to make it upstream. – int_ua Jul 5 '19 at 20:08
  • 1
    Thanks a lot! This was a big issue for me years ago when I worked for a company that made kiosks. We would run them from compact flash cards, usually used for cameras. These cards would only have a certain number of writes to them before they would fail write to the cards. Therefore deleting the file many times, as some others suggest, only makes the problem worse. – earlonrails Jul 9 '19 at 21:21
  • I've made a merge request into the closest thing I could find to upstream: salsa.debian.org/xorg-team/xorg/merge_requests/7 Please add your story about kiosks there. – int_ua Jul 12 '19 at 12:46

In case you still need a solution that keeps logs and has a proper rotation (as it should be for any logged data).

Here is my approach:


exec >>"$ERRFILE" 2>&1


exec > >(logger -t xsession-$USER) 2>&1

in the /etc/X11/Xsession file

That will send all logs to the local syslog server, which can send the logs to the /var/log/syslog file by default and have proper logrotate rules

Alternatively, you can route these messages to a separate file, using syslog configuration and have separate logrotate rules for it altogether.


I faced same problem in redhat linux 6.4 server but i can find which folder or user takes more space by using this command "find / -xdev -type f -size +100000000c -exec ls -lh {} \;" then i deleted manually x session errors by using rm -rf command

  • 1
    This answer does not say HOW to stop the errors. It only says how to delete them. Please update your answer. – Kaz Wolfe Aug 27 '14 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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