I have a minimal systemd service that seems to work normally when started manually using systemctl start my-application.service And it stops normally using the corresponding stop command. For some reason during the system boot, the service is correctly started but immediately stopped. I don't understand why there is a different behaviour in these two cases.
The service is configured like this:
[Unit] After=network.target [Service] ExecStart=start-application.sh ExecStop=stop-application.sh SendSIGKILL=no KillMode=none [Install] WantedBy=default.target The start-application.sh is as follows:
#!/bin/bash . /home/me/app-settings cd /home/me/$APPLICATION/ ./$APPLICATION The $APPLICATION variable is read from /home/me/app-settings. It simply starts a simple application (I even tried with an application that does nothing but waits for a CTRL+c).
I want to underline that, it seems to work fine when I start the service manually but, when on boot, it starts and immediately stops (calling the ExecStop command).
Using systemctl status I have different outputs when started automatically on boot and when launched using systemctrl start.
After boot
○ gp-application.service Loaded: loaded (/etc/systemd/system/gp-application.service; enabled; preset: enabled) Active: inactive (dead) since Mon 2024-02-19 12:03:09 +01; 19s ago Duration: 1.859s Process: 586 ExecStart=start-application.sh (code=exited, status=0/SUCCESS) Process: 746 ExecStop=stop-application.sh (code=exited, status=0/SUCCESS) Main PID: 586 (code=exited, status=0/SUCCESS) CPU: 64ms Feb 19 12:03:08 controller su[757]: (to gp) root on none Feb 19 12:03:08 controller su[757]: pam_unix(su-l:session): session opened for user gp(uid=1000) by (uid=0) Feb 19 12:03:08 controller su[757]: pam_unix(su-l:session): session closed for user gp Feb 19 12:03:08 controller su[760]: (to gp) root on none Feb 19 12:03:08 controller su[760]: pam_unix(su-l:session): session opened for user gp(uid=1000) by (uid=0) Feb 19 12:03:08 controller su[760]: pam_unix(su-l:session): session closed for user gp Feb 19 12:03:08 controller su[763]: (to gp) root on none Feb 19 12:03:08 controller su[763]: pam_unix(su-l:session): session opened for user gp(uid=1000) by (uid=0) Feb 19 12:03:09 controller su[763]: pam_unix(su-l:session): session closed for user gp Feb 19 12:03:09 controller systemd[1]: gp-application.service: Deactivated successfully. If started using systemctl start gp-application.service
● gp-application.service Loaded: loaded (/etc/systemd/system/gp-application.service; enabled; preset: enabled) Active: active (running) since Mon 2024-02-19 12:04:32 +01; 4s ago Main PID: 826 (start-applicati) Tasks: 2 (limit: 9279) Memory: 3.2M CPU: 26ms CGroup: /system.slice/gp-application.service ├─826 /bin/bash /usr/local/bin/start-application.sh └─840 . speedy Feb 19 12:04:33 controller su[837]: (to gp) root on none Feb 19 12:04:33 controller su[837]: pam_unix(su-l:session): session opened for user gp(uid=1000) by (uid=0) Feb 19 12:04:33 controller su[837]: pam_unix(su-l:session): session closed for user gp Feb 19 12:04:33 controller start-application.sh[840]: SPEEDY 7.0.0 Feb 19 12:04:33 controller start-application.sh[840]: RT-APP-COMMON 2.0.0 Feb 19 12:04:33 controller start-application.sh[840]: 12:04:33.587 utils.cpp :117 - utilsInit() Utils successfully initialized. Feb 19 12:04:33 controller start-application.sh[840]: 12:04:33.587 utils.cpp :244 - checkAndCreateRTLockFile() RT lock file: /tmp/.rt-app-lock successfully created. Feb 19 12:04:33 controller start-application.sh[840]: 12:04:33.587 main.cpp :768 - InitProgram() Reading font table Feb 19 12:04:33 controller start-application.sh[840]: 12:04:33.587 fnttable.cpp :144 - ReadFontTable() Error font file font12x8.aff Feb 19 12:04:33 controller start-application.sh[840]: 12:04:33.587 common-parread.cpp :83 - readCommonParameters() EventSocket disabled as requested via parameter file.
loggerafter./$APPLICATION?systemctl status my-application.servicefor more details.