Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

3 Answers 3

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
add comment

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
   blabla
end script
share|improve this answer
add comment

Use the following file contents:

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

task

exec /path/to/your_script.sh
share|improve this answer
add comment

Your Answer

 
discard

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.