I have an application.

I want to run two system units before each time it starts.

The first unit checks for application updates.

The second unit installs any updates is available.

Description=worker application

ExecStart=/usr/bin/node /opt/worker/workerapp/bundle.js


The above unit file results in Exec format error

   Loaded: error (Reason: Exec format error)
   Active: failed (Result: exit-code) since Sat 2018-09-15 22:34:53 UTC; 7min ago
 Main PID: 645 (code=killed, signal=TERM)

Is there a way to specify a service in ExecStartPre?

  • Calling systemctl from within another service is prone to dead locks. – CameronNemo Sep 15 '18 at 23:14
  • Sorry I should have said that the ExecStartPre units are oneshot. – Duke Dougal Sep 15 '18 at 23:15
  • why use separate services just call the commands directly – CameronNemo Sep 15 '18 at 23:17
  • @CameronNemo because each unit has an override.conf file that sets environment variables. – Duke Dougal Sep 15 '18 at 23:18
  • Don't use anything other than the distro's package manager for application updates. Your distro is very likely to have some software to automatically install updates - and that usually means restarting your systemd unit after the update as well. Everything else is more prone to fail and definitely harder to develop / set up – msrd0 Sep 15 '18 at 23:35

You'd want you application to have:


And you'd want appupdate_install.service to have:


You can set these as overrides too. These add to the After list rather than replacing it.

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.