I run a service on my Manjaro machine which reports system information, patch status, etc. back to a central LabTech monitoring server. If I run it directly with the command /home/[username]/ltechagent/ltechagent start, it runs as expected. It does not exit unexpectedly, and appears in the process table as "ltechagent".

I created a systemd service file called labtech.service to manage the LabTech Agent, but found that when I attempt to start it using systemctl start labtech, the process never appears in the process table, and the ltechagent log shows (agent.c:73) Received sigterm. Shutting down the agent within a second or two of starting the service. I have tried setting TimeOutSec, but this does not appear to have any effect.

Service File:

Description = LabTech Agent

ExecStart = /home/[username]/ltechagent/ltechagent start

WantedBy = multi-user.target

Thanks in advance for any insight you might have!

  • 1
    When you launch your application from the command line, does it stay in the foreground? Or does it move itself into the background? With the answer to that question in mind, take a close look at the documentation of the Type parameter in systemd.service(5). – larsks Mar 24 '17 at 18:47
  • Hats off larsks, you got me started in the right direction! While looking into the various service types in the Arch wiki, I came across the RemainAfterExit option. When set to "yes", all appears to be working normally. Thanks! – mblasco Mar 24 '17 at 18:57
  • 1
    I'm glad it worked out. For the record, I strongly suspect you have selected the wrong solution, and that correctly setting the "Type" parameter may be the correct way to go. But if it works, I guess stick with it! – larsks Mar 24 '17 at 18:58

This was resolved by adding RemainAfterExit=yes to the service file.

  • That's not the right way to do this at all, and is the sort of papering over the cracks that one finds in the systemd House of Horror. The right way would involve pointing systemd-sysv-generator at what is obviously a van Smoorenburg rc script, or finding out what the van Smoorenburg rc script actually does and properly replicating that in a systemd service unit. – JdeBP Mar 24 '17 at 22:53
  • @JdeBP, you appear to have more in-depth knowledge of these sorts of issues than I, so I do not doubt that you are correct. Thank you for your input! In this case, I had (and still have) an extremely small amount of time available to address the issue, and the apparent "wrong way" to address it does at least seem to do the trick. – mblasco Mar 27 '17 at 20:08

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.