Difference between revisions of "Create a custom systemd service"
From DevOps Notebook
(Created page with "<pre> # vim /etc/systemd/system/myservice.service </pre> <pre> [Unit] Description=My systemd service. [Service] Type=simple ExecStart=/bin/bash /usr/bin/my_service.sh [Inst...") |
|||
Line 3: | Line 3: | ||
</pre> | </pre> | ||
+ | Created script content | ||
<pre> | <pre> | ||
[Unit] | [Unit] | ||
Line 13: | Line 14: | ||
[Install] | [Install] | ||
WantedBy=multi-user.target | WantedBy=multi-user.target | ||
+ | </pre> | ||
+ | |||
+ | Reload systemd and start script | ||
+ | <pre> | ||
+ | # systemctl daemon-reload | ||
+ | # systemctl start myservice.service | ||
+ | # systemctl enable myservice.service # start on boot | ||
</pre> | </pre> |
Latest revision as of 06:35, 14 May 2020
# vim /etc/systemd/system/myservice.service
Created script content
[Unit] Description=My systemd service. [Service] Type=simple ExecStart=/bin/bash /usr/bin/my_service.sh [Install] WantedBy=multi-user.target
Reload systemd and start script
# systemctl daemon-reload # systemctl start myservice.service # systemctl enable myservice.service # start on boot