[root@ecs-11-132 system]# cat /etc/systemd/system/push-gateway-3.0.0.service
[Unit]
Description=app-portal.service
After=network.target
[Service]
User=root
Group=root
ExecStart=/etc/systemd/system/jenkins/push-gateway-3.0.0.sh
SuccessExitStatus=143
RestartSec=10
Restart=on-failure
[Install]
WantedBy=multi-user.target
[root@ecs-11-132 system]# cat /etc/systemd/system/jenkins/push-gateway-3.0.0.sh
#!/bin/bash
/usr/local/jdk/bin/java -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -jar /data/micros/push-gateway-3.0.0/push-gateway-3.0.0.jar >> /data/logs/micros/push-gateway-3.0.0.log 2>&1
管理
systemctl daemon-reload
systemctl start push-gateway-3.0.0
查看状态
[root@ecs-11-132 system]# systemctl status push-gateway-3.0.0
● push-gateway-3.0.0.service - app-portal.service
Loaded: loaded (/etc/systemd/system/push-gateway-3.0.0.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2019-11-01 17:48:06 CST; 1 weeks 0 days ago
Main PID: 46557 (push-gateway-3.)
Tasks: 47
Memory: 868.7M
CGroup: /system.slice/push-gateway-3.0.0.service
├─46557 /bin/bash /etc/systemd/system/jenkins/push-gateway-3.0.0.sh
└─46558 /usr/local/jdk/bin/java -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:...
Nov 01 17:48:06 ecs-11-132 systemd[1]: Started app-portal.service.