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 recently found out about the upstart "service starter" that Ubuntu is using and that is (apparently) the future to start/stop jobs in Linux.

It's pretty new to me (I was used to the old SysV system of putting scripts in /etc/rc[X].d/) and I don't know if it's possible to stop a service (call the service with the "stop" parameter, although the parameter doesn't seem to matter that much anymore) before other services are stopped.

I want to run a small script that informs a remote server that the machine is shutting down. I need to run that script before the dbus and the network services are taken down. Is there any way of doing it with Upstart? Or... better said, what is the way of doing that through Upstart .conf files? (I'm sure there's a way, I just don't know it)

share|improve this question

You could use a pre-stop directive in upstart config file,

Which will be executed before taking down the service, e.g

pre-stop script
end script
share|improve this answer

if i don't mistake you can do it with same init q, Of course Upstart replaced of inittab and sysv but runlevels are stay.......

share|improve this answer
Right... the problem is that the dbus seems to be shutting off before the scripts in /etc/rcX.d are read (where my script is) so when I try to run the script, I gen an error. Thank you for the suggestion, though – BorrajaX Aug 30 '12 at 14:28

Use the following file contents:

start on runlevel [016] or stopping dbus or deconfiguring-networking


exec /path/to/your_script.sh
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.