Sometimes you have some long running uninterruptible processes or tasks, which should not be terminated or killed under normal circumstances. For this problem systemd provides a simple solution to prevent the shutdown or reboot of a system
You just have to use systemd-inhibit
for starting your process. As long as your process is running, systemd-inihibt
will delay or block a shutdown or reboot task. The following operations can be inhibited:
- shutdown
- sleep
- idle
- handle-power-key
- handle-suspend-key
- handle-hibernate-key
- handle-lid-switch
In default settings you would inhibit idle, sleep and shutdown.
You can view all current inhibits with:
systemd-inhibit --list
To block a shutdown while you are burning a CD, you would run:
systemd-inhibit wodim foobar.iso
You also can inhibit a specific behavior by time using the sleep command. To disable automatic sleep mode for one day, when you close the lid of your laptop, you would run:
systemd-inhibit --what=handle-lid-switch sleep 1d