Linked Questions

1
vote
0answers
100 views

How to force script execution before shutdown or reboot is executed? [duplicate]

I have this service enabled by systemctl: [Unit] Description=The Oracle Database Service After=syslog.target network.target Wants=network.target [Service] LimitMEMLOCK=...
51
votes
4answers
82k views

Execute a command before shutdown

I want to execute a simple command just before the computer shuts down (timing is not essential). For startup, I can use /etc/rc.local; is there something similar for shutdown? Note that I would ...
6
votes
3answers
19k views

Systemd : How to execute script at shutdown only (not at reboot)

There is a lot of solution here to execute a script at shutdown/reboot, but I want my script to only execute at shutdown. I've tried to put my script in /usr/lib/systemd/systemd-shutdown, and check ...
4
votes
2answers
9k views

How to execute scripts in /usr/lib/systemd/system-shutdown/ at reboot or shutdown?

According to this answer and this bug report one can simply drop your script in /usr/lib/systemd/system-shutdown/ or for Debian in /lib/systemd/system-shutdown/ to have it executed at reboot or ...
4
votes
2answers
2k views

Porting old sysvinit habits to systemd

I have a series of script with which I was able to install and configure newly Debian stable systems. To automatically start programs I use /etc/rc.local but for other cases I had to manually change ...
5
votes
2answers
6k views

Umount network drives with systemd before shutdown

My shutdown takes quite a long time (I'm on Debian 8.1) and I found out that it can be fixed by unmounting the network drive before shutting down the system. Apparently the network gets disconnected ...
4
votes
1answer
1k views

How to write a Systemd unit that will fire before networking goes down

I want to run a script when a user shuts their computer down, but it needs networking. So I'd like it to run when the system is heading for shutdown (or restart), but it needs to run before anything ...
2
votes
1answer
3k views

kick off a systemd service just before shutdown

I am developing a systemd shutdown script (unit file) for a postgresql database and I followed the below two posts but could not get it to work. How to run a script with systemd right before shutdown?...
2
votes
1answer
2k views

How to turn off scroll lock LED, indicating keyboard layout, when the PC is turned off

I edited the file /etc/X11/xorg.conf.d/90-keyboard-layout.conf: Section "InputClass" Identifier "keyboard-all" MatchIsKeyboard "on" MatchDevicePath "/dev/input/event*" Driver "evdev" ...
1
vote
1answer
968 views

Delay system shutdown with systemd?

What is the best way to delay system shutdown by arbitrary amount of time in systemd? I'm trying the following unit: root@ip-172-30-3-65:~# cat /etc/systemd/system/delay_by30.service [Unit] ...
4
votes
1answer
695 views

Execute code on shutdown on Fedora 19

I need to catch any OS shut down and execute some actions before letting the OS be shutted down. I'm using Fedora 19 and C++. I'm able to catch a shutdown signal given by the console with the ...
0
votes
2answers
323 views

Can't connect to local MySQL server through socket

All commands in debian9's interactive non-login shell (graphical mode). I want to backup mysql before reboot or shutdown. who test tty7 2018-02-01 18:26 (:0) test@world:~$ pwd /home/test ...
2
votes
0answers
236 views

How do I change the time limit on systemd shutdown scripts?

I have a script that I want to run just before shutdown on my CentOS 7 machine. A process to do so using systemd is well-described in this previous question. Basically, I just drop the script I want ...
5
votes
0answers
192 views

How can a systemd service detect that system is going to power off?

I have a systemd service controlling some hardware, let's take lamps as a good example. It is OK to restart the service, or reboot the PC, because it is safe that the lamps are left switched on for ...
0
votes
1answer
47 views

How to add a delay to the power button for accidental bumps

I have a miniature PC here with a large and prominent power button on the front which is easy to bump accidentally. The system is running CentOS 7 with systemd. I already know that I can set ...