0

I'm having some trouble figuring out how the services work on CentOS. Right now I have the following service file:

[Unit]
Description=SomeDescription
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/script

[Install]
WantedBy=multi-user.target

This will launch a script that calls an executable that will never return:

#!/bin/bash
export LD_LIBRARY_PATH=SOMEPATH && cd SOMEOTHERPATH && ./EXECUTABLE

The executable never returns. When I launch the service, it runs for a while but then exits due to timeout:

Job for selftester.service failed because a timeout was exceeded. See "systemctl status selftester.service" and "journalctl -xe" for details.

I noticed that if I change explicitly the script to run the executable in the background it works:

#!/bin/bash
export LD_LIBRARY_PATH=SOMEPATH && cd SOMEOTHERPATH && ./EXECUTABLE &

Is that the correct implementation? Thanks in advance

  • The environment variable and the working directory can both be set in the service directly, so why are they set separately in a script? – muru Aug 14 at 9:38
  • @muru I didn't know I could do that. I followed your suggestions and I could get it to work. Thanks! – Ricardo Alves Aug 14 at 9:53

Your Answer

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

Browse other questions tagged or ask your own question.