Dav*_*lan 7 upstart services 12.04
运行 12.04,我有以下新贵工作~/.init/:
# myjob
start on net-device-up
stop on [!12345]
script
echo ">> hello from user script" >> ~/tmp/upstart.log
end script
Run Code Online (Sandbox Code Playgroud)
重新启动我的机器后
service myjob start
# => myjob: unrecognised service
Run Code Online (Sandbox Code Playgroud)
initctl 确实列出了作业,但在没有 sudo 的情况下运行它会引发错误:
initctl start myjob
# => initctl: Rejected send message, 1 matched rules; type="method_call", sender=":1.100" (uid=1000 pid=13349 comm="initctl start thunderbird ") interface="com.ubuntu.Upstart0_6.Job" member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
Run Code Online (Sandbox Code Playgroud)
我希望能够使用service或initctl不使用sudo. 我误解了什么?
谢谢
jam*_*unt 12
几点:
默认情况下,Ubuntu 中不启用用户作业。看:
在创建任何类型的 Upstart 作业后,您永远不需要重新启动——它们会被 Upstart 自动检测到(使用 inotify)。
该service命令不是 Upstart 的一部分——它是操作 SysV 作业的 SystemV 工具。但是,Upstart 提供了 SystemV 兼容性,这样 Upstart 系统作业也可以通过service(为方便起见)进行操作。Upstart 等效命令是start、stop和restart。
对于用户作业,您必须使用start, stopand, restart(或initctl等价物)。
最后,请注意,用户作业目前非常基础。我们计划在 12.10 中显着增强它们,但现在请注意:
/bin/sh -e。这-e也很重要(man sh详情)。Upstart 只会在用户作业环境中设置最少的变量集。因此,您可能应该像HOME这样设置变量:
env HOME=/home/james
看:
| 归档时间: |
|
| 查看次数: |
8272 次 |
| 最近记录: |