Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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

share|improve this answer
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 Dec 19 '13 at 21:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.