Skip to content

Commit

Permalink
Sierra processes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuron committed Oct 21, 2016
1 parent 752f672 commit 9dc3e41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mountclean
==========

This is a daemon for Mac OS X which periodically checks for leftover mounts of Network Home Directories and for stale processes belonging to users which are no longer logged in.
In a way, this resembles what [uphclean](http://www.microsoft.com/de-de/download/details.aspx?id=6676) did for Windows 2000/XP: it makes sure that when a user logs out, the session really ends. This is necessary so that no files are still locked when the user later logs into a different client machine. It is also useful in environments where many users share a single computer and you would otherwise end up with dozens of leftover home mounts and hundreds of stale processes.
In a way, this resembles what [uphclean](https://support.microsoft.com/en-us/kb/837115) did for Windows 2000/XP: it makes sure that when a user logs out, the session really ends. This is necessary so that no files are still locked when the user later logs into a different client machine. It is also useful in environments where many users share a single computer and you would otherwise end up with dozens of leftover home mounts and hundreds of stale processes.

The script is run every two minutes and checks for mounts in /home. For each one, it checks whether the corresponding user has any processes running. If he only has background processes (names listed in the script) running, these are terminated and the home directory is unmounted.
So processes and mounts belonging to a user currently logged in locally or via SSH are never touched. Also, users who e.g. started screen sessions before logging out are not touched.
Expand Down Expand Up @@ -33,4 +33,5 @@ Troubleshooting
Good places to look when things don't work as expected are:
- Mounted home directories: `ls /home`
- Running processes: `ps axu | grep -v '^root\|^_'`
- Log output written by mountclean: `grep mountclean /var/log/system.log`
- Log output written by mountclean: `grep mountclean /var/log/system.log` (only on OS X 10.11.6 and below)
- Output from running mountclean: `sudo mountclean.py`
8 changes: 7 additions & 1 deletion mountclean.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def log(msg):
'GPUToolsAgent',
'com.apple.MailSe',
'com.apple.spotli',
'nsurlstoraged',
# new in Sierra
'trustd',
'lsd',
'com.apple.Dictio',
'CalNCService',
# Dropbox client
'Dropbox',
'dbfseventsd',
Expand Down Expand Up @@ -106,7 +112,7 @@ def log(msg):
ps = ps.splitlines()
ps = [p.strip() for p in ps[1:]]
extraps = set(ps)-set(killprocs)
log("%d processes still running: %s" % (len(extraps), ", ".join(extraps)))
log("%d processes still running for %s: %s" % (len(extraps), user, ", ".join(extraps)))

if len(extraps) == 0:
kill_users.append(user)
Expand Down

0 comments on commit 9dc3e41

Please sign in to comment.