Hey David..

Thanks for the thoughts on this...

Would you mind posting/pasting what your code/shell scripts are/is.. I'm sure someone will need something similar in life!


-Peace!


On Thu, Jul 28, 2016 at 5:26 PM, David A. De Graaf <dad@datix.us> wrote:
On Thu, Jul 28, 2016 at 02:53:34PM -0400, Tom Horsley wrote:
> On Thu, 28 Jul 2016 14:37:41 -0400
> David A. De Graaf wrote:
>
> > Have I overlooked something obvious?  Is there a way to make systemd
> > perform the simple function 'shutdown' smoothly, reliably and quickly?
> > If anyone knows how, I would love to hear it.
>
> I can't make systemd itself work, but I've been using an
> outside systemd solution for a while now: I setup
> an alias for the "reboot" command that arranges to
> kill off all the things systemd unreasonably waits
> for, then does a real reboot.
>
> Since systemd now has nothing to stop it, it reboots
> rather fast (until something new shows up which I have
> to track down and add to my list :-).
>
> My current set of things to do before shutdown includes:
>
> umount -l -t nfs -a
> apachectl -k stop
> kill all the "user deamon" process trees.
>
> The user daemon stuff is handled by a program
> described here:
>
> http://tomhorsley.com/game/punch.html
>

Thank you Tom Horsley for all your brilliant insights,
and especially this one.

I have taken your 'locate-user-daemons.c' program, lock, stock
and barrel, stirred with some other condiments and come up with
this alternate /usr/local/bin/reboot script that works for me:

  $ cat /usr/local/bin/reboot
  #   Precede normal reboot command with unmounting of nfs mounts
  #   and stop other impediments to progress
  /usr/local/bin/nfsumount
  /usr/bin/pkill -9 gkrellmd
  /usr/local/bin/locate-user-daemons | /bin/bash -i
  systemctl reboot

where /usr/local/bin/nfsumount contains:
  #   Forcibly umount all autofs-mounted filesystems
  mount | grep /net/ |
      sed -e 's/.*on //' | sed -e 's/ .*//' |
      sort -u | tac |
  while read fn; do
      umount -fl -t nfs $fn &
  done

Your simpler  'umount -l -t nfs -a'  works for mounts listed
in /etc/fstab, but not for autofs-mounted filesystems, I believe.

I (re)discovered that gkrellmd takes a full 90 sec to be stopped
by systemd, but no time at all by pkill;  I added that.
As you say, more may turn up.

Now the 'reboot' command makes my systems shut down smoothly, reliably
and quickly, as proper Linux systems should.

--
        David A. De Graaf    DATIX, Inc.    Hendersonville, NC
        dad@datix.us         www.datix.us


"Those who hear not the music, think the dancers mad."