在 /usr/lib/systemd/system 下创建文件 my-jenkins.service
[Unit]
Description=description
After=jenkins.service
[Service]
Type=simple
User=root
Group=root
PIDFile=/usr/lib/jenkins/jenkins.pid
ExecStart=/usr/lib/jenkins/jenkins.sh
#ExecStart=/usr/bin/java -jar -server -Xms1024m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=512m -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8888 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20 >> /var/log/jenkins/jenkins.log 2>&1 &
ExecReload=
ExecStop=kill -9 `cat /var/run/jenkins-service.pid`
PrivateTmp=true
[Install]
WantedBy=multi-user.target
执行 systemctl start 文件名就行了