我想继续在后台运行我的服务,以继续检查特定进程是否在运行。
服务。
[Unit]
Description=msf
After = network.target
[Service]
WorkingDirectory =/home/
ExecStart=/home/msfservice.sh
[Install]
WantedBy=multi-user.target
服务状态:
Loaded: loaded (/etc/systemd/system/msf.service; enabled; vendor
preset: disabled)
Active: inactive (dead) since Fri 2018-11-02 01:20:44 EDT; 3min 52s ago
Process: 537 ExecStart=/home/msfservice.sh (code=exited,
status=0/SUCCESS)
Main PID: 537 (code=exited, status=0/SUCCESS)
脚本:
#!/bin/bash
i=`ps -eaf | grep -i msfconsole |sed '/^$/d' | wc -l`
echo $i
if [[ $i > 1 ]]
then
echo "service is running"
touch running
else
echo "Not Runnig"
touch notrunning
fi
但是,我的服务在重新启动时按预期工作,但是每当我尝试运行msf的第二个实例时,它都不会在主目录中写入任何文件。 任何人都可以帮助保持此服务在后台运行吗?
谢谢