Re: Service not run, although enabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# systemctl status bestcrypt-fs
● bestcrypt-fs.service - Mount Bestcrypt containers
     Loaded: loaded (/etc/systemd/system/bestcrypt-fs.service; enabled; vendor preset: disabled)
     Active: active (exited) (thawing) since Mon 2023-08-07 11:17:18 EEST; 20min ago
    Process: 2645396 ExecStart=/usr/local/sbin/bcmount (code=exited, status=0/SUCCESS)
   Main PID: 2645396 (code=exited, status=0/SUCCESS)

How come that the via "ExecStart=" given bash script does not get run?

It clearly *did* run, it says bcmount was successfully executed 20 minutes earlier and the service has been active since then. Were you trying to start your service again with "systemctl start" ?  Because that will do nothing when the service is already active. You'd need to stop the service first (which will cause bceject to be invoked), or use "systemctl restart" which will stop the service before starting it.

Note btw that because you put "exit 0" at the end of your script it will always claim success even if the actual mount command fails. Simply removing the "exit 0" will fix that since then the script's exit code will be that of the last command executed. Another fix is adding the -e flag to #!/bin/sh which will make your script fail if any command it executes fails instead of just ignoring failures.

Do you have a clue? I even changed "oneshot" into "simple", striked "RemainAfterExit", etc.

Don't do that, Type=oneshot and RemainAfterExit=true are correct for your service.

Type=oneshot means systemd will wait for the ExecStart program to exit when starting the service, i.e. your service won't be considered to have started successfully until bcmount has finished successfully. As long as bcmount is still running your service will be considered "starting" and if it takes too long then systemd will kill it with a timeout.

In contrast, Type=simple means systemd will start the ExecStart program asynchronously and immediately consider the service to be active, so starting your service will always successfully complete immediately before bcmount has even started executing, and if bcmount fails then the service will just go to "failed" state afterwards.

RemainAfterExit=true means that your service will continue to be considered "active" after the ExecStart program exits successfully, which is exactly what you want when this program is responsible for starting your service and then exits. When RemainAfterExit=false the ExecStart program is assumed to *be* the service, hence when it exits the service will stop (hence ExecStop will be invoked).

Is there any way I can see the whole process verbosely?

You can enable debug logging in systemd using "systemctl log-level debug" and turn it back off using "systemctl log-level info".

Matthijs

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux