Ubuntu下systemd服务的配置


1. 在/lib/systemd/system目录下创建服务启动脚本testservice.service

2. 文件内容如下:

 1 [Unit]
 2 Description=TestService
 3  
 4 [Service]
 5 ExecStart=/home/test/exec   # 可执行文件路径
 6 WorkingDirectory=/home/test/    #工作目录
 7 Restart=always
 8 User=car
 9 ExecReload=/bin/kill -SIGHUP $MAINPID
10 ExecStop=/bin/kill -SIGINT $MAINPID
11  
12 [Install]
13 WantedBy=default.target

3. sudo systemctl start testservice.service


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM