I'm looking to start or restart a systemd service and immediately tail the output, but if the service exits while tailing, abort as though I had interrupted the command.
- I don't want to include output from any previous invocations.
- I want to keep the colorization and other features (see example below) of
journalctl. - I want to interrupt the command proper, not just stop output.
The following is what I use currently:
systemctl start myservice & journalctl --unit myservice --since=now --no-hostname --exclude-identifier=podman -f I start the service in the background, that I can follow the output immediately, instead of after startup scripts have been executed.
I'm already doing this in a script, so I'm prepared to add some amount of logic, but I prefer not to involve any additional packages.