systemd - running script before syslog terminates during shutdown

Hi OpenSuse friends,
I want to run a script during shutdown sequence before syslog has been terminated.

This is my config.

Linux1:/etc/systemd/system # cat my_mounts.service
[Unit]
Description=mount my private mount points

Requires=local-fs.target syslog.target rsyslog.service
After=local-fs.target syslog.target rsyslog.service

[Service]
ExecStart=/etc/init.d/my_mount
Type=oneshot
RemainAfterExit=yes

[Install]

The script /etc/init.d/my_mount is executed during shutdown. I can show this by logging into a dedicated file ( i.e. echo >> xx )
Comparing timestamps I see that rsyslog is always terminated before my script is started.

What’s the right config for this service?

Thanks for your help in advance

Here is a couple of more things to add/try:

[Unit]
Description=mount my private mount points
Requires=local-fs.target syslog.target rsyslog.service
After=local-fs.target syslog.target rsyslog.service
**Before=shutdown.target**

[Service]
ExecStart=/etc/init.d/my_mount
Type=oneshot
RemainAfterExit=yes
**StandardOutput=syslog**

Thank You,

Hi,
I’ve tested your proposal. Still the script is being started after syslog stopped.

The output in my personal log file

Sun Feb 5 09:28:34 CET 2012: /etc/init.d/my_mount stop

The output in /var/log/messages

Linux1:~ # cat /var/log/messages | grep 09:28
Feb 5 09:28:31 Linux1 kernel: Kernel logging (proc) stopped.
Feb 5 09:28:31 Linux1 rsyslogd: [origin software=“rsyslogd” swVersion=“5.8.5” x-pid=“575” x-info=“http://www.rsyslog.com”] exiting on signal 15.
Linux1:~ #

My script is always executed a few seconds after syslog is stopped.
Here my script for completeness.

Linux1:~ # cat /etc/init.d/my_mount
#!/bin/bash
logger “starting $0 $1 ($#) $$ …”
D=date
echo "$D: $0 $1 " >> /var/log/my_mounts
logger “$0 done”

Thanks for your help!

You attempts to use a fixed font are appreciated, but using CODE tags is better: http://forums.opensuse.org/english/information-new-users/advanced-how-faq-read-only/451526-posting-code-tags-guide.html

On 02/04/2012 09:36 PM, kay dilbert wrote:
>
> I want to run a script during shutdown sequence before syslog has been
> terminated.

i believe it would help to say what version of which operating system
you are running (because if running 12.1 the answer might be different
if you are using systemv or systemd)…

and, it might be nice to know which desktop environment you are using,
if any, because it might be possible to have the DE call the script as
it shuts down…

but, i don’t know (as you have not said, where i can find it) if it is a
script you need executed as yourself (normal user) or root
user…because that will have an impact on the answer…

on the other hand, i’m not smart enough to figure out what you are
trying to do–i guess it is clear to all the previous answer givers, but
not me…


DD http://tinyurl.com/DD-Caveat http://tinyurl.com/DD-Hardware
http://tinyurl.com/DD-Software
Read what Distro Watch writes: http://tinyurl.com/SUSEonDW

Hi,
I’m using 12.1 with systemd and KDE. Latest patches installed.
The script shall be executed by root and mount some truecrypt containers during boot. During shutdown those containers shall be unmounted.

My log shows that the script is executed in both cases, i.e. during boot with parameter start and during shutdown with parameter stop. Thus I can mount and umount. Just syslogging is not possible during shutdown.

Regards

On 2012-02-05 12:26, kay dilbert wrote:
> My log shows that the script is executed in both cases, i.e. during
> boot with parameter start and during shutdown with parameter stop. Thus
> I can mount and umount. Just syslogging is not possible during shutdown.

The problem is that few people know about systemd scripts. I could help
with systemv, but not with systemd. You could try posting on the opensuse
mail list, because one or two of the systemd maintainers read around there.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Why not do it all int fstab those get mounted at start and umounted at quit???

On 2012-02-05 18:46, gogalthorp wrote:
>
> Why not do it all int fstab those get mounted at start and umounted at
> quit???

Not within sight of syslog.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)