systemctl简单配置
1.编写eval的启动脚本,例如
vim /home/iristar/hyc/eval/run.sh
#!/bin/bash
cd /home/iristar/hyc/eval
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./dll
java -jar ./target/evalserver-1.0-SNAPSHOT.jar --spring.config.addition-location=./application.properties >/dev/null 2>&1 &
在此之前插入最简单的方案(临时使用比较好)
vim /etc/rc.local
#!/bin/bash
touch /var/lock/subsys/local
/bin/bash /home/iristar/hyc/eval/run.sh
chmod 777 /etc/rc.local
2.编写eval的systemd服务脚本(推荐)
vim /etc/systemd/system/eval.service
[Unit]
Description=eval
After=network.target
[Service]
User=root
Type=forking
ExecStart=/bin/bash /home/iristar/hyc/eval/run.sh
ExecReload=/bin/kill -s HUP $MINPID
ExecStop=/bin/kill -s QUIT $MINPID
PrivateTmp=true
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
~
//给个权限
chmod 777 /etc/systemd/system/eval.service
3.使用systemctl命令启动等
 #启动服务
 systemctl start eval
 #停止服务
 systemctl stop eval
 #重新加载服务
 systemctl reload eval
 #重启服务
 systemctl restart eval
 #查看服务状态
 systemctl status eval
 //开机自启
 systemctl enable eval
 //取消开机自启
 systemctl disable eval
 
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号