一般来说,我对systemd和linux还是很陌生,所以您必须在这里忍受。
我的服务编写如下:
[Unit]
Description=Run Master Print Service.
[Service]
Type=simple
ExecStart=/usr/bin/cwsLogging02.sh cwsMPS.service mps
[Install]
WantedBy=multi-user.target
我想运行的shell脚本:
Date=`date '+%Y-%m-%d %H:%M:%S'`
echo "$1 service started at ${DATE}" | systemd-cat -p info
while true
do
systemctl is-active $1
IS_SYSTEM_ACTIVE=$?
if [ $IS_SYSTEM_ACTIVE = 0 ]; then
echo "$2 is running."
elif [ $IS_SYSTEM_ACTIVE = 3]; then
echo "$2 is inactive."
else
echo "$2 status: $IS_SYSTEM_ACTIVE"
fi
sleep 5
done
当我直接从命令行运行shell脚本时,它运行良好,但是当我尝试运行sudo systemctl status cwsMPS
(在启动并启用后),I get this message.
I also have this problem,但是我不确定这两个问题是否相关。
关于在这里做什么的任何想法?