I have recently discovered systemd-run, which I use to do long running processes needed to set up a server (initial database import, that kind of thing). (This is on Ubuntu 18.04)

Is it possible to make systemd-run wait, and not run, until another (systemd) unit has finished? When I set up a regular systemd service, I can use After=/Depends=/etc. to make one service 'wait' until another has started.

What I'd like to do is start one systemd-run service which (say) does a data import, then 'start' another which creates some indexes and needs the data there, but I'd like to 'block'/'wait' until the first service has finished.

Is this possible?

  • 1
    I believe you can use Before and After if you specify it like this: systemd-run -p After=network-online.target <your command>, I'm not 100% sure, though. Maybe you can/ need to use Wants= as well. – Lenniey May 3 at 8:58

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.