How to create a Systemd service in Linux
Article Number: 715 | Rating: Unrated | Last Updated: Mon, Dec 7, 2020 8:38 PM
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.
- Create a file named your-service.service and include the following:
Description=<description about this service>
User=<user e.g. root>
WorkingDirectory=<directory_of_script e.g. /root>
ExecStart=<script which needs to be executed>
- 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
There are no attachments for this article.
There are no comments for this article. Be the first to post a comment.
RHEL: ACLs basics
Viewed 2162 times since Sun, May 27, 2018
Viewed 7421 times since Fri, Sep 28, 2018
RHEL7: Configure automatic updates.
Viewed 841 times since Wed, Oct 17, 2018
Open SSL HowTo: Decode SSL Certificate
Viewed 4902 times since Mon, Feb 18, 2019
linux manual tools
Viewed 1114 times since Fri, Sep 28, 2018