1

I have a standard systemd service (A = gpsd.service) running at startup.

I have a custom systemd service (B = my_gps_logger.service) which is not enabled by default, so that a user has to manually start it (for diagnosis). The logger service is a bash script with gpscat /dev/ttyPS1 > my_log.log

If I restart gpsd, it fails because my logger service has the device open.

I worked around that by using BindsTo=gpsd.service in my logger service.

So now if I restart gpsd, my logger service stops and gpsd restarts ok.

HOWEVER, it does not restart my logger service !!

I don't know if PartOf= is the answer. It feels wrong (and my tests show it didn't restart the logger).

But I don't want to restart my logger service anytime gpsd is started. Only if the logger service was running and was stopped/restarted because gpsd was restarted. If the logger service wasn't running, then I don't want it to autmomatically start up.

Any ideas how I can configure systemd services to achieve this?

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.