linux设置jar服务开机启动

1.编辑earth.service

[Unit]
Description=earth
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
User=root
WorkingDirectory=/home/ross/earth
ExecStart=/home/ross/jdk1.8.0_251/bin/java -jar /home/ross/earth/earth-0.0.1-SNAPSHOT.jar &

[Install]
WantedBy=multi-user.target

2. 放到/usr/lib/systemd/system

3. 执行chmod 775 earth.service

4. 执行systemctl daemon-reload

5. 启动systemctl start earth.service

6. 设置开机启动systemctl enable earth.service

posted @ 2021-09-11 12:19  jason47  阅读(291)  评论(0编辑  收藏  举报