How To Configure and setup Systemd Service on Linux Mint 20.3
To Setup and Configure Systemd service On Linux Mint 20.3
Introduction:
Systemd isáthe first daemon to start during booting and the last daemon to terminate during shutdown. The Systemd daemon serves as the root of the user space's process tree; The first process (PID 1) has a special role on Unix systems, As it replaces the parent of a process when the original parent terminates.
Installation Procedure:
Step 1 : Check the OS version by using the below command
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20.3
Release: 20.3
Codename: una
Step 2 : Edit the .sh file in the name of linuxhelp by using the below command
root@linuxhelp:~# nano linuxhelp.sh
Step 3 : Execute Permission given to linuxhelp.sh file by using the below command
root@linuxhelp:~# chmod +x linuxhelp.sh
Step 4 : Enter the system service default path by using the below command
root@linuxhelp:~# cd /etc/systemd/system
Step 5 : Configure the linuxhelp.service file by using the below command
root@linuxhelp:/etc/systemd/system# nano linuxhelp.service
Step 6 : Start the linuxhelp service by using the below command
root@linuxhelp:/etc/systemd/system# systemctl start linuxhelp
Step 7 : Check the status of linuxhelp service by using the below command
root@linuxhelp:/etc/systemd/system# systemctl status linuxhelp
ΓùÅ linuxhelp.service
Loaded: loaded (/etc/systemd/system/linuxhelp.service; static; vendor preset: enabled)
Active: active (running) since Wed 2022-04-20 05:15:45 IST; 8s ago
Main PID: 4857 (linuxhelp.sh)
Tasks: 2 (limit: 4571)
Memory: 1.3M
CGroup: /system.slice/linuxhelp.service
Γö£ΓöÇ4857 /bin/bash /root/linuxhelp.sh
ΓööΓöÇ4895 sleep 1
Apr 20 05:15:45 linuxhelp systemd[1]: Started linuxhelp.service.
Apr 20 05:15:45 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:45 AM IST
Apr 20 05:15:46 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:46 AM IST
Apr 20 05:15:47 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:47 AM IST
Apr 20 05:15:48 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:48 AM IST
Apr 20 05:15:49 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:49 AM IST
Apr 20 05:15:50 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:50 AM IST
Apr 20 05:15:51 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:51 AM IST
Apr 20 05:15:52 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:52 AM IST
Apr 20 05:15:53 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:15:53 AM IST
Step 8 : View the syslog file by using the below command
root@linuxhelp:/etc /systemd/system# tail /var/log/syslog
Apr 20 05:16:24 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:24 AM IST
Apr 20 05:16:25 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:25 AM IST
Apr 20 05:16:26 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:26 AM IST
Apr 20 05:16:27 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:27 AM IST
Apr 20 05:16:28 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:28 AM IST
Apr 20 05:16:29 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:29 AM IST
Apr 20 05:16:30 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:30 AM IST
Apr 20 05:16:31 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:31 AM IST
Apr 20 05:16:32 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:32 AM IST
Apr 20 05:16:33 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:16:33 AM IST
Step 9 : View the log while it is running every second by using the below command
root@linuxhelp:/etc/systemd/system# journalctl -u linuxhelp -f
-- Logs begin at Sat 2022-04-02 00:59:05 IST. --
Apr 20 05:17:06 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:06 AM IST
Apr 20 05:17:07 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:07 AM IST
Apr 20 05:17:08 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:08 AM IST
Apr 20 05:17:09 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:09 AM IST
Apr 20 05:17:10 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:10 AM IST
Apr 20 05:17:11 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:11 AM IST
Apr 20 05:17:12 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:12 AM IST
Apr 20 05:17:13 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:13 AM IST
Apr 20 05:17:14 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:14 AM IST
Apr 20 05:17:15 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:15 AM IST
Apr 20 05:17:16 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:16 AM IST
Apr 20 05:17:17 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:17 AM IST
Apr 20 05:17:18 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:18 AM IST
Apr 20 05:17:19 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:19 AM IST
Apr 20 05:17:20 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:20 AM IST
Apr 20 05:17:21 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:21 AM IST
Apr 20 05:17:22 linuxhelp linuxhelp.sh[4857]: The current time is Wednesday 20 April 2022 05:17:22 AM IST
^Z
[2]+ Stopped journalctl -u linuxhelp –f
Step 10: Stop the service of linuxhelp by using the below command
root@linuxhelp:/etc/systemd/system# systemctl stop linuxhelp
Step 11 : Edit the linuxhelp.service file by using the below command
root@linuxhelp:/etc/systemd/system# nano linuxhelp.service
Step 12 : Enable the service of linuxhelp by using the below command
root@linuxhelp:/etc/systemd/system# systemctl enable linuxhelp
Created symlink /etc/systemd/system/mylti-user.target.wants/linuxhelp.service → /etc/systemd/system/linuxhelp.service.
Step 13 : Reload the daemon service by using the below command
root@linuxhelp:/etc/systemd/system# systemctl daemon-reload
Step 14 : Restart the service of linuxhelp by using the below command
root@linuxhelp:/etc/systemd/system# systemctl restart linuxhelp
Step 15 : Check the status of linuxhelp by using the below command
root@linuxhelp:/etc/systemd/system# systemctl status linuxhelp
ΓùÅ linuxhelp.service - My linuxhelp service
Loaded: loaded (/etc/systemd/system/linuxhelp.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-04-20 05:21:56 IST; 8s ago
Main PID: 5297 (linuxhelp.sh)
Tasks: 2 (limit: 4571)
Memory: 1.1M
CGroup: /system.slice/linuxhelp.service
Γö£ΓöÇ5297 /bin/bash /root/linuxhelp.sh
ΓööΓöÇ5335 sleep 1
Apr 20 05:21:56 linuxhelp systemd[1]: Started My linuxhelp service.
Apr 20 05:21:56 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:21:56 AM IST
Apr 20 05:21:57 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:21:57 AM IST
Apr 20 05:21:58 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:21:58 AM IST
Apr 20 05:21:59 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:21:59 AM IST
Apr 20 05:22:00 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:22:00 AM IST
Apr 20 05:22:01 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:22:01 AM IST
Apr 20 05:22:02 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:22:02 AM IST
Apr 20 05:22:03 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:22:03 AM IST
Apr 20 05:22:04 linuxhelp linuxhelp.sh[5297]: The current time is Wednesday 20 April 2022 05:22:04 AM IST
With this, the process of Configuring Systemd Service On Linux Mint 20.3 has comes to an end
There might be any number of reasons responsible for a service crash or failure such as misconfigurations, lack of system resources, file/data corruption, etc.