Ubuntu下systemd服务的配置

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

2. 文件内容如下:

[Unit]
Description=TestService

[Service]
ExecStart=/home/test/exec   # 可执行文件路径
WorkingDirectory=/home/test/    #工作目录
Restart=always
User=car
ExecReload=/bin/kill -SIGHUP $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=default.target

3. sudo systemctl start testservice.service

你可能感兴趣的:(Ubuntu下systemd服务的配置)