Quantcast
Channel: openSUSE Forums
Viewing all articles
Browse latest Browse all 40713

12.3 halt.local does not run at shutdown

$
0
0
I have some commands I would like to run at shutdown on my OpenSuse 12.3 system. I understand halt.local would be a logical place to put the commands, but on my system, I've been able to determine that halt.local never runs when the system shuts down.

I've set up this test to document the issue:

Contents of halt.local:
linux1:~> cat /etc/init.d/halt.local
#! /bin/sh
#
# Copyright (c) 2002 SuSE Linux AG Nuernberg, Germany. All rights reserved.
#
# Author: Werner Fink, 1998
# Burchard Steinbild, 1998
#
# /etc/init.d/halt.local
#
# script with local commands to be executed from init on system shutdown
#
# Here you should add things, that should happen directly before shuting
# down.
#
echo "$(date) running halt.local" >>/var/log/halt.log

If I run halt.local manually, it in fact echo's the message to /var/log/halt.log as it should:
Sun Aug 3 09:58:37 EDT 2014 running halt.local


If I execute a "shutdown -r now" command, the system reboots, and I never get the message in /var/log/halt.log

The halt-local service looks like this:
linux1:~>systemctl status halt-local
halt-local.service - /etc/init.d/halt.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/halt-local.service; static)
Active: inactive (dead)
CGroup: name=systemd:/system/halt-local.service


linux1:~>cat /usr/lib/systemd/system/halt-local.service
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.


[Unit]
Description=/etc/init.d/halt.local Compatibility
ConditionFileIsExecutable=/etc/init.d/halt.local
DefaultDependencies=no
After=shutdown.target
Before=final.target


[Service]
Type=oneshot
ExecStart=/etc/init.d/halt.local
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes

If I manually start the service, I get this:
linux1:~>systemctl start halt-local
linux1:~>systemctl status halt-local
halt-local.service - /etc/init.d/halt.local Compatibility
Loaded: loaded (/usr/lib/systemd/system/halt-local.service; static)
Active: active (exited) since Sun, 2014-08-03 10:22:40 EDT; 6s ago
Process: 2743 ExecStart=/etc/init.d/halt.local (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/halt-local.service


Aug 03 10:22:40 linux1.randyburton.me systemd[1]: Started /etc/init.d/halt.local Compatibility.

And if I now check /var/log/halt.log, I can see that halt.local ran just fine:
Sun Aug 3 10:22:40 EDT 2014 running halt.local




However, a "shutdown -r now" still does not cause halt.local to run.

Any ideas on what's going on here?

I have a workaround - defined my own service, as described here:
https://www.suse.com/communities/con...-and-shutdown/
and in stop.d, I just put a link to /etc/init.d/halt.local:
linux1:~> ls -lh /etc/init.d/my_maintenance.d/stop.d/
total 0
lrwxrwxrwx 1 root root 22 Aug 3 09:26 halt.local -> /etc/init.d/halt.local

So, now, halt.local does in fact run when I reboot, but this seems a bit of a Rube Goldberg solution to me.

Any suggestions on how to get this to work the way it's supposed to work?

One last comment on a minor issue... in the default OpenSuse /etc/init.d/halt.local file, in the comments, "shuting" should be "shutting".

Thanks for the assistance,
Randy

Viewing all articles
Browse latest Browse all 40713

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>