[mosh-devel] [TOOL RELEASE] Killing Stale Mosh Sessions: Mosh Cleaner

Jason A. Donenfeld Jason at zx2c4.com
Mon Jan 27 09:33:09 EST 2014


Hey folks,

Frequently, my server's "pinky" or "finger" output fills up with stale
sessions from users. I've written a little cronjob tool to help clean
these up:

   http://git.zx2c4.com/mosh-cleaner/about/
   http://git.zx2c4.com/mosh-cleaner/tree/clean-mosh.c

It kills processes according to this algorithm:

For each user:
    If user only has one mosh session:
        continue
    For each mosh session other than the most recent of that user:
        If session is currently connected:
            continue
        If session is older than kill-time:
            kill session

kill-time begins at 24 hours and splits in half each time, until a
minimum of 1 hour. This amounts to the following semantics:

* Most recent session: never killed
* Any currently connected session: never killed
* Second most recent session: killed if not used for 24 hours
* Third most recent session: killed if not used for 12 hours
* Forth most recent session: killed if not used for 6 hours
* Fifth most recent session: killed if not used for 3 hours
* Sixth most recent session: killed if not used for 1.5 hours
* Seventh most recent session: killed if not used for 1 hour
* Eighth most recent session: killed if not used for 1 hour
* Ninth most recent session: killed if not used for 1 hour

Thoughts? Suggestions?

Jason



More information about the mosh-devel mailing list