16

I have visited over 30 different forum questions about this very same issue but none of them have been able to point me in the right direction.

I don't care what is causing the issue. I don't care what the error messages say.

I want to completely disable this from happening.

I don't want to disable all logging on my system just this .xsession-errors file.

I have tried the /dev/null thing it doesn't work. I made it read-only, just creates a new file .xsession-errors.jkhbjhjh. I even commented out the file generation in /etc/X11/xsession.

I'm running an ecommerce webserver that will be decommissioned in less than 90 days. I just need to keep the sites up long enough to get them all moved over to my new system. This log file is filling up my HDD 2 to 3 times a week rendering my webstores inoperable.

Just to be clear, I'd like to know how to disable .xsession-errors logging. I'm running Ubuntu 9.10 with gnome. I know it's no longer supported but again, this server is being decommissioned in less than 90 days it shouldn't matter.

0

6 Answers 6

16

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

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

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
2

just do

rm /wherever/you/have/.xsession-errors
ln -s /dev/null /wherever/you/have/.xsession-errors

and restart the computer (this, you do to close all programs that were using .xsession-errors)

All access to .xsession-errors will be redirected to /dev/null, a "file" meant to receive text and just throw it away

3
  • I see now that you said that /dev/null did not work. Did you reset the server (or close the programs writing to .xsession ?). Without doing either, the programs will just ignore you and keep writing to the file they knew
    – josinalvo
    Aug 17, 2012 at 14:40
  • 1
    Seems to work without restart for me if I run it as: rm /wherever/you/have/.xsession-errors;ln -s /dev/null /wherever/you/have/.xsession-errors
    – jeteon
    May 14, 2016 at 14:24
  • 2
    It probably should. Programs might keep writing to a deleted file, and spending space on the hard drive. The file is no longer acessible, but still 'there'. The file only gets 'truly' deleted when the program closes the file (or closes itself). So, a computer reset ensures that no programs are keeping the file. But is only relevant in an improbable case.
    – josinalvo
    May 20, 2016 at 20:58
2

The workaround for this is rather dependent on the desktop manager that you are using. Changing the /etc/X11/Xsession file works fine in some cases, but if you are using gnome, for instance, you should add the following lines to ~/.gnomerc:

rm -r ${HOME}/.xsession-errors
ln -s /dev/null ${HOME}/.xsession-errors

Hopefully that subtlety will help someone.

1
  • 3
    This will not work, as the X server process still has a file handle opened and will continue to write to it.
    – eMPee584
    Sep 24, 2019 at 12:05
2

I have met the same situation like you and tried those suggested solutions on the net and seems all failed.

Finally, I have commented out the line "ERRFILE=$HOME/.xsession-errors" inside the file /etc/X11/Xsession of my Ubuntu.

Then the .xsession-errors file does not appear again.

From my testing, this error log file is for the service vino-server which you can find in your process list (ps -ef|grep vino). It is a VNC server process. I wonder there are some programs in the net keep trying to login our server by a VNC client so to produce a lot of error message in this log file.

Power

0

If you've tried this solution but found it to be unsatisfactory, then I would simply write a cron entry that deletes the file every hour.

crontab -e

Add the following entry:

@hourly rm -rf /path/to/xsession/files/.xsession-errors*

Quick and dirty, but functional!

If you want it to be even faster, just change @hourly to */2 * * * *.
This will delete the files every two minutes.

2
  • 6
    do test that. but you may find it not working, for the same reason that I mentioned in my proposed solution: After you delete a file, if there was a program using it, it'll just keep writing to it. It wont be acessible to new programs, but it'll still be there until the program closes
    – josinalvo
    Aug 17, 2012 at 16:27
  • 4
    Disappointing that this is still the top answer for this question (not as disappointing as the fact that the bug persists) since it indeed doesn't work: the file keeps getting written and eats all your disk space until you restart.
    – bnaul
    Mar 14, 2013 at 20:24
0

It seems that the issue is still relevant despite it's age. I just got the same trouble on my notebook with SSD. i need to move it to TMPFS, i got /tmp mounted in. all advices about moving files, truncating it, chowning/chattring doesn't work for my xubuntu 13.04. it seems that the filepath is hardcoded into xfce binaries. i grepped all the filesystem. there are no occurencies of that file except /etc/X11/Xsession , and changing ERRFILE there leads to nothing.

By the way any actions with these files in /etc/rc.local doesn't make any sesnse because rc.local triggers besore Xsession starts.

So i created a file in my homedir called .xfce-customizations and added following lines in there:

ln -sf $(mktemp) /home/remort/.xsession-errors
ln -sf $(mktemp) /home/remort/.xsession-errors.old

After that i added this file to autostart with my xsession in 'Settings Manager' -> 'Session and Startup - Application Autostart'. After reboot and loggin into my xfce both of the files were symlinked to the tempfiles. So you still have your logs able to analyze during uptime, so it's quite clean solution.

Not the answer you're looking for? Browse other questions tagged .