新贵,一份工作定义开始,一份停止

ben*_*zen 7 scripts upstart

嗨,我刚刚发现了 ubuntu upstart(etc/init/* 脚本)。我想用它来运行一个特定的应用程序。这个应用程序是通过命令行运行的,但是有一个参数来启动应用程序的一个实例,另一个参数来停止它(比如“开始”和“停止”)有没有办法使用 upstart ?

hto*_*que 7

它应该像创建文件一样简单/etc/init/myjob.conf

description    "My Job"

# start conditions for automatic start
# stop conditions for automatic stop

pre-start exec /path/to/program start
post-stop exec /path/to/program stop
Run Code Online (Sandbox Code Playgroud)

然后你应该能够sudo start myjob开始和sudo stop myjob停止。

有关更多信息,请参阅http://upstart.ubuntu.com