0

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.

1 Answer 1

1
systemctl --no-block start myservice journalctl --unit myservice --since=now --no-hostname --exclude-identifier=podman -f | awk '/service: Deactivated successfully/ { print; exit; }; { print; }' 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.