Controlling Ubuntu's and Fedora's Upstart (the init replacement) - page 2
Controlling Startup Events
You can also set scripts to run before and after the start of a job:
pre-start exec echo "Starting jobname"
echo "Started jobname"
pre-stop and post-stop work in exactly the same way.
To choose where the output should go, use the console stanza.
sends the output to /dev/console, while none sends it to /dev/null. The default is logged which sends it to the logger; you can also set it to owner, in which case the process becomes the owner of the console and can receive input from the keyboard.
As in the runlevel 3 script above, you can start on particular runlevels, on the startup event, or in response to another job, e.g.
start on started cupsd
would start this service when cupsd starts. If you want to start or stop a service manually, you can use the start and stop commands (usually found in /sbin/):
You can also get the status of a job with status servicename.
Finally, you can list all jobs with initctl list, and emit a custom event with initctl emit eventname. So if we have a job which runs after a ping event:
exec echo "ping"
it can be run with initctl emit ping, and the console will show this output:
There are various further improvements planned to upstart, including a scheduler so that events can be generated at specific intervals or at particular times, and the ability to react to an event caused by the change of a file or directory. There's development information available if you're interested in following or helping out with the development. The Upstart wiki may also be helpful for both users and developers.
Sponsored by BlackBerry
BlackBerry® Enterprise Server Express enables businesses of any size to quickly and easily get started with the BlackBerry solution. It provides advanced BlackBerry smartphone features with no additional software or user license fees, and works with any Internet-enabled BlackBerry data plan or a BlackBerry enterprise data plan. Download now!