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.
- 1Linux Top 3: Network Security Toolkit, Untangle NG Firewall and IPFire
- 2Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 3Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 4Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 5Linux 4.6 Charred Weasel adds USB 3.1 Support