Hi, today we will learn how to create a linux service. I use Ubuntu 20.04 to test. Have fun!
1
|
/etc/systemd/system/test_service.service
|
Example file content:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[Unit]
Description=Demo test service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=**root**
ExecStart=**COMMAND TO EXECUTE**
[Install]
WantedBy=multi-user.target
|
You can see the full service defination here.
1
2
|
sudo systemctl daemon-reload
sudo systemctl start test_service.service
|
1
|
sudo systemctl enable test_service.service
|
1
|
sudo systemctl status test_service.service
|
1
|
sudo systemctl stop test_service.service
|