I have found systemd-run which allows one to run processes in the background once off ("transient services"). I always specify the service unit name with --unit $NAME. But if I have already run the systemd-run command and my process is running, then systemd-run will fail, with non-zero exit code. Is there anyway to tell systemd-run to be more idempotent and not fail in this case?
Currently I'm doing:
systemctl is-active $NAME || systemd-run --unit $NAME $COMMAND Is there a better way?
This is on Ubuntu 18.04, with the current systemd for that (version 237?)