systemd 格式的 Upstart 作业

systemd 格式的 Upstart 作业

我看过启动官方文档,但我无法将我的 Upstart 作业复制到 systemd。

新贵职位:

description  "evercam_media"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
limit nofile 1000000 1000000

respawn
chdir /
setuid root
setgid root

exec watch -n1 '/usr/local/bin/run_evercam_media.sh'

post-stop exec sudo pkill beam

我在阅读文档文件时几乎复制了相同的内容

[Unit]
Description=evercam_media
[Service]
User=root
Group=root
WorkingDirectory=/
ExecStart=/bin/sh -ec "exec watch -n1 '/usr/local/bin/run_evercam_media.sh'"
ExecStopPost=sudo pkill beam
Restart=always

[Install]
WantedBy=multi-user.target

但每当我这样做时systemctl daemon-reloadsystemctl status evercam_media.service我只得到错误

● evercam_media.service - evercam_media
   Loaded: loaded (/etc/systemd/system/evercam_media.service; enabled; vendor preset: enabled)
   Active: inactive (dead) (Result: exit-code) since Tue 2017-07-18 08:41:23 CEST; 12s ago
  Process: 32596 ExecStart=/bin/sh -ec exec watch -n1 '/usr/local/bin/run_evercam_media.sh' (code=exited, status=1/FAILURE)
 Main PID: 32596 (code=exited, status=1/FAILURE)

Jul 18 08:41:22 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_media.service: Unit entered failed state.
Jul 18 08:41:22 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_media.service: Failed with result 'exit-code'.
Jul 18 08:41:23 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_media.service: Service hold-off time over, scheduling restart.
Jul 18 08:41:23 Ubuntu-1604-xenial-64-minimal systemd[1]: Stopped evercam_media.
Jul 18 08:41:23 Ubuntu-1604-xenial-64-minimal systemd[1]: evercam_media.service: Start request repeated too quickly.
Jul 18 08:41:23 Ubuntu-1604-xenial-64-minimal systemd[1]: Failed to start evercam_media.
root@Ubuntu-1604-xenial-64-minimal:/etc/systemd/system# 

正如他们在文档中提到的那样.. exec将会如此/bin/sh 'exec',我已尝试上述方法,但失败了。但如果我在终端中执行此操作,exec watch -n1 '/usr/local/bin/run_evercam_media.sh'一切都会开始。

更新:

我只想让每个人运行 1 秒的 sh 脚本,这Watch是我最终使用的工具。

相关内容