java程序设置开机自启
[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 set folder=D:\home\logs\dev if not exist %folder% md %folder% start /b D:\jdk1.8.0_351\bin\javaw -jar xxxxx.jar --spring.profiles.active=dev -Dfile.encoding=utf-8 > %folder%\java.log 2>&1 &