Linux 中创建系统服务
条评论At times you create a script and then you want to have the scripts controlled by systemd or in some cases you wish to have the scripts getting restarted by itself when it is killed due to some reason. In such cases systemd in Linux helps to configure services which can be managed. To do so follow the following steps.
cd /etc/systemd/system
Create a file named your-service.service and include the following:
1 | [Unit] |
For Python specific projects which include virtual environment:
1 | [Unit] |
OR
1 | [Unit] |
- Reload the service files to include the new service.
sudo systemctl daemon-reload
- Start your service
sudo systemctl start your-service.service
- To check the status of your service
sudo systemctl status example.service
- To enable your service on every reboot
sudo systemctl enable example.service
- To disable your service on every reboot
sudo systemctl disable example.service
- 本文链接:https://blog.charjin.top/2023/02/27/linux/create-systemd-service/
- 版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!
分享