[Unit] Description=Java camera service After=network.target [Service] WorkingDirectory=/home/app/java Environment="LD_LIBRARY_PATH=/home/app/java/lib" ExecStart=/opt/java8/bin/java -jar /home/app/java/polaris-admin.jar Restart=no User=Admin RestartSec=30 StandardOutput=append:/home/app/java/log.out StandardError=append:/home/app/java/log.out Type=simple [Install] WantedBy=multi-user.target
WorkingDirectory:替換成你jar的位置
Environment:jar包啟動要依賴的環境,有就加沒有就不加
ExecStart:從jdk的bin目錄指定你的jar包位置
Restart:設定重啟方式
User:用該裝置的角色
RestartSec:每隔多少次重啟一次
StandardOutput、 StandardError:設定日誌位置
重新載入 :sudo systemctl daemon-reload
重啟:sudo systemctl restart myapp.service
啟動:sudo systemctl start myapp.service
檢視狀態:sudo systemctl status myapp.service
-
@echo off javaw -jar "D:\app\polaris-admin.jar"