I have written a bash script which I want to run every 60s (don't worry, I have tried the Script out, it runs perfectly).
Now I wanted to implement it in systemd
.service file, but so far it doesn't restart. The script is beeing executed one time and ends with returncode 0 and then the service stops (for ever). So, it just runs ones, but then it ends.
It won't restart. I tried out many different things with
StartLimitBurst, but nothing worked.
Here is my .service-file:
[Unit] Description=ExampleScript [Service] User=myuser Restart=allways RestartSec=60s ExecStart=/bin/bash /home/myuser/start.sh StartLimitIntervalSec=0 [Install] WantedBy=multi-user.target
Maybe someone of you guys know about System.d and could help me? Thank you very much!
service-status while running the script:
* examplescript.service - ExampleScript Loaded: loaded (/usr/lib/systemd/system/examplescript.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2018-06-29 23:58:04 CEST; 1s ago Main PID: 31860 (bash) Memory: 15.6M CGroup: /system.slice/examplescript.service |-31860 /bin/bash /home/myuser/start.sh |-31862 /bin/bash /home/myuser/script/subscript.sh `-31871 python /home/myuser/script/subscript.py Jun 29 23:58:04 mysystem systemd: Started ExampleScript.
service-status after script is finish with rc0:
* examplescript.service - ExampleScript Loaded: loaded (/usr/lib/systemd/system/examplescript.service; enabled; vendor preset: disabled) Active: inactive (dead) since Fri 2018-06-29 23:58:48 CEST; 2min 42s ago Process: 31860 ExecStart=/bin/bash /home/myuser/start.sh (code=exited, status=0/SUCCESS) Main PID: 31860 (code=exited, status=0/SUCCESS) Jun 29 23:58:04 mysystem systemd: Started ExampleScript.
...systemd is so freaking complicated, cron-job was so much easier