Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have the following bash script on debian with the LSB header:

# Provides: shutdown_vms
# Required-Start:
# Required-Stop: gdm vmware $local_fs $remote_fs $network
# Default-Start:
# Default-Stop: 0 2 3 4 5 6
# Short-Description: Shutdown vms
# Description: Shutdown vms

The script shutdown guest vms when host is shutdown. It runs fine for shutdown (0) and reboot (6).

The problem is, how do I make it run for user logout (when user log out, it should shutdown the vms)?

The rc2.d directory shows: K01shutdownvms which is the first script to run.

Is it possible to run the script on logout without using gdm PostSession/rc.local/bash.logout etc?

share|improve this question

If I understand you correctly, you are asking if Debian's upstart can do it. No it can't. You have to use the mechanisms that you've mentioned.

But please re-consider the whole thing, because it is extremely rare practice to shutdown a system service (i.e. possibly used by multiple users) on one user's logout.

share|improve this answer

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.