Putting NetBeans log directory on a temporary file system

Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

Whenever you do something, anything, in NetBeans, it will write to the uigestures file in the NetBeans log directory, .netbeans/8.2/var/log for NetBeans 8.2. I finally got tired of hearing my disk being written to every time I pressed a key so I decided to put the log directory on a temporary file system in memory. I imagine this will also be good for the future health of an SSD drive.

I'm using OpenSUSE Leap so there may be variations on other distros.

OpenSUSE will automatically create a directory for me in /run, which uses a tmpfs file system. My personal directory is called /run/user/1000 since 1000 is my uid. There is an environment variable, XDG_RUNTIME_DIR, that points to this directory.

The following script sets up the log directory and ensures that your NetBeans profile has a symbolic link to it:

#!/bin/bash

# Create log directory for NetBeans in the temporary directory.
mkdir -p $XDG_RUNTIME_DIR/netbeans-log

# Determine latest NetBeans version and its var directory.
VERSION=$(ls -t -1 ${HOME}/.netbeans/|head -n 1)
VARDIR=${HOME}/.netbeans/${VERSION}/var

# Ensure that the log directory is a link to the one in the temporary directory.
if [ ! -L ${VARDIR}/log ]
then
    rm -r $VARDIR/log
    ln -s $XDG_RUNTIME_DIR/netbeans-log $VARDIR/log
fi

Save it somewhere suitable as for example netbeans-log-tmpfs and make it executable. Then make sure it is run when you log in. Since I use KDE, I use Startup/Shutdown in System Settings.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.