How to add Upstart event-type tasks to the system under the upstart Mechanism
/********************************************************************* * Author : Samson * Date : 11/15/2014 * Test platform: * 3.13.0-24-generic * GNU bash, 4.3.11(1)-release * *******************************************************************/
Currently, the system startup mechanism used by LinuxMint is based on ubuntu's upstart. The corresponding configuration file directory is/etc/init. According to upstart, create a configuration file that can start a task directly using initctl emit eventname on the command line, and create the file mytestup under/etc/init. conf. The content is as follows:
Start on mytestyy
Task
Exec/bin/date>/tmp/yygydjkthh
When the event is mytestyy, run the/bin/date command to write the result to the/tmp/yygydjkthh file.
After saving the file, you can restart the system or directly use the command to update the upstart configuration file on the command line to make it take effect:
Sudo initctl reload-configuration
Then run the command to trigger the event on the command line:
Sudo initctl emit mytestyy
The task can be executed: mytestup. Check that/tmp/yygydjkthh already exists, indicating that the task is successfully executed;
Upstart emit principle:
Creates an associated table for all tasks. When an emit event is detected, the table matches the table. If the event name is consistent, the corresponding task or service is executed;
Ref: http://upstart.ubuntu.com/cookbook/#event