Systemd Services
We can make use of systemd to auto run custom scripts in the background instead of manually opening a terminal session to run them. Its the same concept used by Sonarr, Radarr, etc...
To get started we need to create a new file in the systemd location.
-
Go to
/etc/systemd/system
-
Right click in a empty space and select
Open as Root
. Enter server credentials and a new Elevated Privileges window will open.Note: Root access is needed to create or edit in this directory.
-
Create and name a new file. I usually name it the same as the script file.
<SCRIPT_NAME>.service
-
Get the source code (1), copy/past the code into the newly created
<SCRIPT_NAME>.service
file from the previous step. -
Now we need to enable the service file.
-
Note: You can find the source code to all scripts by clicking the euronvault/eScripts link at the top of this wiki.
# Reload the systemctl daemon
sudo systemctl daemon-reload
# Enable the service
sudo systemctl enable <SCRIPT_NAME>.service
# Starting the service
sudo systemctl start <SCRIPT_NAME>
# Checking status of service
sudo systemctl status <SCRIPT_NAME>
This new service will auto start when the server is rebooted. You can check the status of this service using the code above and/or using Stacer.