# [TIP] Clear NX (No Machine) session cache during boot-up

## m27315

If you use No Machine (NX, or FreeNX), you may have run into a problem where the box is rebooted with active sessions still open.  The dead session files can block the same users from re-establishing a new session, once the box boots back up. You can SSH into the box and remove the sessions as root each time a user complains, or you can ensure that it is done automagically at startup, every time, like so:

```
echo '/bin/rm -rf /usr/NX/var/db/*/session*' >> /etc/conf.d/local.start
```

Since discovering the local.start and local.stop files, I have been piling all kind of useful commands that ensure my box comes up (or goes down) in a known good, clean state.

BTW, the NX error message, which indicates you need to wipe out the session files, looks like this:

```
NX> 203 NXSSH running with pid: 3144

NX> 285 Enabling check on switch command

NX> 285 Enabling skip of SSH config files

NX> 285 Setting the preferred NX options

NX> 200 Connected to address: MY_IP_ADDRESS on port: 22

NX> 202 Authenticating user: nx

NX> 208 Using auth method: publickey

HELLO NXSERVER - Version 3.2.0-7 - LFE

NX> 105 Hello NXCLIENT - Version 3.2.0

NX> 134 Accepted protocol: 3.2.0

NX> 105 Set shell_mode: shell

NX> 105 Set auth_mode: password

NX> 105 Login 

NX> 101 User: MY_USERID

NX> 102 Password: ********

NX> 103 Welcome to: MY_MACHINE user: MY_USERID

NX> 105 Listsession --user="MY_USERID" --status="suspended\054running" --geometry="3200x1200x32+render+fullscreen" --type="unix-kde" 

NX> 127 Available sessions: 

Display Type             Session ID                       Options  Depth Screen         Status      Session Name

------- ---------------- -------------------------------- -------- ----- -------------- ----------- ------------------------------

1007    unix-kde         AED37B9C496FCEFDE3CB6047DED2632F FRD--PSA    32 3200x1200      Running     MY_MACHINE

NX> 148 Server capacity: not reached for user: MY_USERID

NX> 105 Restoresession --link="adsl" --backingstore="1" --encryption="1" --cache="128M" --images="512M" --shmem="1" --shpix="1" --strict="0" --composite="1" --media="1" --mediahelper="esd" --session="MY_MACHINE" --type="unix-kde" --geometry="3200x1140" --fullscreen="1" --client="winnt" --keyboard="pc102\057en_US" --id="AED37B9C496FCEFDE3CB6047DED2632F" --resize="1" 

NX> 900 Suspending session with id: AED37B9C496FCEFDE3CB6047DED2632F for user: MY_USERID

NX> 595 ERROR: A fatal error occurred in NX Server.

NX> 595 ERROR: The exception id is: 2D006DE2. To get detailed information about

NX> 595 ERROR: the error search for the string 2D006DE2 in the system log

NX> 595 ERROR: file (usually '/var/log/messages').

NX> 500 ERROR: Last operation failed.

NX> 280 Exiting on signal: 15
```

HTH

----------

## jlpoole

I installed neatx, Google's implementation of the NX server that doesn't have the capacity limitation that the free version from No Machines has.

```
localhost sessions # eix neatx

[I] net-misc/neatx

     Available versions:  (~)0.3.1_p43-r1

     Installed versions:  0.3.1_p43-r1(04:29:45 10/07/09)

     Homepage:            http://code.google.com/p/neatx/

     Description:         Google implementation of NX server

localhost sessions #

```

And I ran into the problem of a prior crashed session preventing me from logging back in.  I followed the directions above; however, the same cached session continued to block me:

Although I had previous sessions from nxser, removing them did not remove the session that was cached.  Suspecting that NeatX was the culprit I determined that NeatX was caching sessions and found them under /var/lib/neatx/sessions, so I did the same kind of housecleaning on that directory as recommended in this thread:

```
localhost sessions # pwd

/var/lib/neatx/sessions

localhost sessions # ls

1778B6C57810744C38682A84F6A66138  6DC797A63E86FCC1B39945D87BD9F01A

40C4F3C7EAAE552404F229EE0007D49C

localhost sessions #  rm -R *

```

After removing the neatx sessions, I was able to successfully login from Windows.

----------

