I am still confused about systemd services being active vs the process still running vs not running etc.
Let's say I have the following basic shell script called my_script.sh :
#!/bin/sh touch /my_dir/my_file.txt echo "Hello from my_script.sh" >> /my_dir/my_file.txt
I have a system service called my_service.service which calls my_script.sh as follows :
[Unit] Description=my service [Service] Type=simple ExecStart=sh /my_dir/my_script.sh RemainAfterExit=yes Restart=always [Install] WantedBy=multi-user.target
The fact that I have
Restart=always , does this mean that as soon as my shell script finishes executing, it should execute again, and again, hence continuously writing to the file?
My understanding is that with
Restart=always , the service is restarted regardless if there was a clean exit or not. This statement I don't understand properly. Will there be a clean exit after my_script.sh executes.
Now the line
RemainAfterExit=yes , in my case, what is the effect of having this line defined or not?
Thanks in advance for clearing up any doubts.