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)


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

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.......

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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