I run a desktop computer, which typically is shut down for the nights and often also during the day, when not in use or left unattended. I usually shut it down from GUI (KDE 4.10), sometimes - from KDM, and sometimes I also use a good, old /sbin/shutdown.

Now: it happens that a task is running, which should not be interrupted, such as a backup, video recording, etc. For obvious reasons, in such cases I would prefer that the shutdown is postponed until the job is finished. Ideally a warning should be issued to the user, but that's not always possible. How to achieve this?

Some time ago I wrote a script executed in a runlevels 0 and 6, which checked for existance of a flag file, and postponed the process until the file disappeared. It was not ideal, but efficient enough. But in recent versions of my distribution init was replaced with systemd, which runs /etc/init.d/ scripts in parallel, so the hack does not work any more.

If it's of any importance, I use OpenSuse 12.3, kernel 3.7.10, KDE 4.10.

1 Answer 1


You should use systemd-inhibit. All you need to do to prevent the system from going down is to prefix a command with "systemd-inhibit".

For example, if I wanted to ensure that the system wouldn't shut down, idle, sleep, etc. while I was burning a CD, I would do:

systemd-inhibit brasero

When brasero was closed, the system would be allowed to execute normal shutdown policies again.

For more information, see man systemd-inhibit

  • Thanks for the hint. It does not seem to work on my system though. :( I tried several cobinations of a user invoking the command in KDE window, in background, in terminal screen, with root priviledges... I was always able to shut the system down both from KDE, KDM and invoking shutdown.
    – Jasio
    Commented Dec 19, 2013 at 21:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .