2017-01-11 16 views
0

我正在测试如何在CentOS7上使用.service文件运行脚本。Program.service ExecStart失败,但程序本身运行

的脚本是一个非常简单的循环,只是为了确保它运行:

​​

该脚本运行正常的根或测试用户,如果我手动启动。

的Program.service文件看起来是这样的:

[Unit] 
Description=Program 

[Service] 
Type=forking 
RemainAfterExit=yes 
PIDFile=/u/Test/Locks/start.pid 
EnvironmentFile=/u/Test/Config/environ 
Environment="Base="sudo -u sirsi '/u/Test/Bincustom/Program " "Stop=halt force'" "Start=cycle force'"" 
ExecStart=/bin/sh $Base$Start 
ExecStop=/bin/sh $Base$Stop 

[Install] 
WantedBy=multi-user.target 
WantedBy=WebServices 
WantedBy=BCA 

错误永远是:

● Program.service - Program 
    Loaded: loaded (/usr/lib/systemd/system/Program.service; enabled; vendor preset: disabled) 
    Active: failed (Result: resources) since Wed 2017-01-11 14:53:10 MST; 1s ago 
    Process: 12014 ExecStart=/bin/sh $Base$Start (code=exited, status=0/SUCCESS) 

Jan 11 14:53:09 localhost.localdomain systemd[1]: Starting Program... 
Jan 11 14:53:10 localhost.localdomain systemd[1]: PID file /u/Test/Locks/start.pid not readable (yet?) after start. 
Jan 11 14:53:10 localhost.localdomain systemd[1]: Failed to start Program. 
Jan 11 14:53:10 localhost.localdomain systemd[1]: Unit Program.service entered failed state. 
Jan 11 14:53:10 localhost.localdomain systemd[1]: Program.service failed. 

很显然,我做错事的。服务,但对我的我的生活我仍然想念它。

回答

0

的问题是在该行:

环境= “基地=” 须藤-u SIRSI“/ U /测试/ Bincustom /程序“的 ”Stop =停止力'“”开始=周期力量“ “” ExecStart =/bin/sh的$基地$开始 ExecStop =/bin/sh的$基地$停止

显然。服务文件不承认的变量。

我也有一个问题与sudo不被允许运行我的测试脚本。 我不得不将sudo添加到测试脚本中。

相关问题