I'm trying to execute a daemon program from a systemd service, however when I start the script from a command prompt, either manually (systemctl start) or as part of the debian installation (dpkg -i myapp.deb) the command execution does not return back to the command prompt.




I can confirm that executed daemon program itself does not 'return', since it is a daemon. Also, when I reboot the system, the service runs the daemon successfully.

I was expecting, however, when starting the service from 'systemctl start', that the service would run the daemon in the background, and return back to the command prompt, especially after specifying 'Type=forking'. I have also tried setting 'Type=Simple' but the outcome is the same.

I've looked at What are ways of creating a daemon using systemd? and Systemd service runs without exiting but neither of these solve my problem.

If someone could help, this would be great.



1 Answer 1


I dealt with this exact issue just last night. It took two things to fix. Because selinux policy and environment variables can be quite different between what systemd has versus a logged in super user, testing on command line can give a false positive. With selinux enforcing, the difference can be dramatic. Rather than fail, systemd attempts to run it indefinitely, waiting for a succees (exit 0). So, to get to the bottom of it, run systemctl start my-daemon, then CTL + C to cancel out of service start, then run systemctl status my-daemon. The status will definitely show what is failing and why it hasn't exited.

The other thing is under [service] section, in addition to other parameters, use


Though Type=forking might be appropriate for your job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.