Sample Header Ad - 728x90

Unmount user home directory in a delayed background process after logging out

0 votes
0 answers
105 views
The home directory of user bob is mounted by a superuser from elsewhere. bob himself is a sudoer, he is logged in and is happily using his mounted home directory. He finishes his work and wants to run a script which will log him out *and* unmount his home directory. He tries:
cd / # switch to a directory other than /home/bob to avoid keeping it busy
bash -c 'sleep 5 && sudo umount /home/bob /dev/null & disown
gnome-session-quit --no-prompt
He gets logged out but then, when alice logs in (also a sudoer), she sees bob's home directory still mounted after a while. Apparently, the umount command fails for some reason. How can bob reliably unmount it upon logging out?
Asked by Greendrake (459 rep)
Jul 6, 2023, 01:51 PM