(原创)Ubuntu18注册lmgrd服务,实现开机自启动 Synopsys工具
首先进入服务文件夹
cd /lib/systemd/system
然后新建service文件
sudo touch edatools.service
然后编辑为以下内容,其中路径以实际为准:
[Unit]
Description=Synopsys tools active service
After=network.target
[Service]
Type=forking
ExecStart=/usr/synopsys/active_tools.sh
ExecReload=/usr/synopsys/active_tools.sh
ExecStop=/usr/synopsys/active_tools.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Alias=edatools.service
然后新建对应的sh文件(注意,这里实际只实现了启动的功能,如果需要停止的,参考sh文件自己改)
#!/bin/bash
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
echo "[$LOGTIME] startup run..." >>/root/startup_run.log
service ssh start >>/root/startup_run.log
echo "Detecting system status, please wait!"
rm -rf /tmp/lmstat.log
/usr/local/eda_tools/scl/2018.06/linux64/bin/lmstat >>/tmp/lmstat.log
if [ `grep -c "Cannot" /tmp/lmstat.log` -ne '0' ];then
echo "Detected that the service is not running, trying to restart..."
sudo kill -9 $(lsof -i:27000 -t)
wait
rm -rf /root/EDA_INITIAL.log
cd /usr/local/eda_tools/scl/2018.06/linux64/bin && LD_PRELOAD=./snpslmd-hack.so ./lmgrd -c /usr/local/eda_tools/Synopsys.dat >> /root/EDA_INITIAL.log
sleep 10s
wait
else
echo "System service detected started!"
exit 0
fi
rm -rf /tmp/lmstat.log
/usr/local/eda_tools/scl/2018.06/linux64/bin/lmstat >>/tmp/lmstat.log
if [ `grep -c "Cannot" /tmp/lmstat.log` -ne '0' ];then
echo "Detected that the service is not running, trying to restart..."
sudo kill -9 $(lsof -i:27000 -t)
wait
rm -rf /root/EDA_INITIAL.log
cd /usr/local/eda_tools/scl/2018.06/linux64/bin && LD_PRELOAD=./snpslmd-hack.so ./lmgrd -c /usr/local/eda_tools/Synopsys.dat >> /root/EDA_INITIAL.log
sleep 10s
wait
else
echo "System service detected started!"
exit 0
fi
rm -rf /tmp/lmstat.log
/usr/local/eda_tools/scl/2018.06/linux64/bin/lmstat >>/tmp/lmstat.log
if [ `grep -c "Cannot" /tmp/lmstat.log` -ne '0' ];then
echo "It is detected that the service is not running, please contact the administrator..."
exit 0
fi
然后运行
sudo systemctl daemon-reload
sudo systemctl enable edatools.service
就已经实现了开机启动程序。
如果需要立即开启服务,可以运行
service edatools start
也可以查看服务状态
service edatools status