Systemd is a Linux system tool that one of its features is bootstrapping start and manage system processes.
A systemd service makes it easy to start, stop, restart scripts as well as configure it to start at boot.
Create a systemd service
Suppose that we have a script in /usr/bin/jdk.sh Also suppose that there is a Linux user named jdk in group ourgroup
- Create the file
/etc/systemd/system/jdk.serviceand paste the following into it:
[Unit] Description=Run myscript service as user jdk SyslogIdentifier=myscript [Service] Type=simple User=jdk Group=ourgroup ExecStart=/bin/bash /usr/bin/jdk.sh [Install] WantedBy=multi-user.target
2. Start the service to verify that it works:
sudo systemctl start jdk.
3 . Enable the service so it runs on bootup:
sudo systemctl enable jdk.
4. Restart your system and then verify that the MailHog service is running by running
systemctl | grep jdk.