Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to stop (and start again later) several services manually. How can I figure out the correct sequence that respects the dependencies?

In ancient times I could parse the contents of e. g. /etc/rc2.d and follow the given sequence. How would that work with upstart?

What I need is a script:

Input: list of services

Output: this list sorted such that these services can be safely started int that order

I want to backup my system; prior to the backup I want to stop services that might lead to an inconsistent backup (like the mail system), or that might have some data in memory and not on the file system (like databases).

share|improve this question
4  
Basically you're asking how to interrogate upstart for a list of work items in order to do something manually that upstart was designed to accomplish for you. Maybe you want to give some more context on what you want to do or rethink your approach and widen the scope of your question. –  JoBo Aug 26 '13 at 10:21
1  
I want to backup my sytem; prior to the backup I want to stop services that might lead to an inconsistent backup (like the mail system), or that might have some data in memory and not on the file system (like databases). –  user187380 Aug 26 '13 at 11:16
    
If you use Upstart to stop/start known services (mail, database), other services that rely upon them should automatically stop/start, too. You shouldn't need to manually parse those relationships. –  user535733 Dec 12 '13 at 16:14

1 Answer 1

You can add stop on service starting stanza to the services that you want to stop whenever the backup event fire up. Something like this:

# this is my test service

start on runlevel [2345]
stop on runlevel ![2345]
stop on backup starting
start on backup stoping

exec service --daemon

you must replace backup with the name of the service that starts using upstart. There's also the fire event stanza but this is a bit more complicated since it requires you to modify both, the service you are stoping for backups and the service that is starting to do the backup.

share|improve this answer

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.