Skip to content

Instantly share code, notes, and snippets.

@WGH-
Created November 7, 2022 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WGH-/b9bcf1087e17c2cb1414a0ee2a16dc1b to your computer and use it in GitHub Desktop.
Save WGH-/b9bcf1087e17c2cb1414a0ee2a16dc1b to your computer and use it in GitHub Desktop.
Started /bin/sh -c echo $JOURNAL_STREAM; stat -L -c '%n dev=%d ino=%i' /proc/self/fd/{0,1,2}.
test-7daa95055a8c4c89b72528a3c38df2cf.service: Deactivated successfully.
8:306630
/proc/self/fd/0 dev=5 ino=5
/proc/self/fd/1 dev=8 ino=306630
/proc/self/fd/2 dev=8 ino=306630
Started /bin/sh -c echo $JOURNAL_STREAM; stat -L -c '%n dev=%d ino=%i' /proc/self/fd/{0,1,2}.
8:312524
/proc/self/fd/0 dev=5 ino=5
/proc/self/fd/1 dev=8 ino=312524
/proc/self/fd/2 dev=8 ino=312524
test-7daa95055a8c4c89b72528a3c38df2cf.service: Deactivated successfully.
Started /bin/sh -c echo $JOURNAL_STREAM; stat -L -c '%n dev=%d ino=%i' /proc/self/fd/{0,1,2}.
8:314453
/proc/self/fd/0 dev=5 ino=5
/proc/self/fd/1 dev=8 ino=314452
/proc/self/fd/2 dev=8 ino=314453
test-7daa95055a8c4c89b72528a3c38df2cf.service: Deactivated successfully.
Started /bin/sh -c echo $JOURNAL_STREAM; stat -L -c '%n dev=%d ino=%i' /proc/self/fd/{0,1,2}.
8:304775
/proc/self/fd/0 dev=5 ino=5
/proc/self/fd/1 dev=8 ino=304774
/proc/self/fd/2 dev=8 ino=304775
test-7daa95055a8c4c89b72528a3c38df2cf.service: Deactivated successfully.
#!/bin/bash
set -e
cmd="echo \$JOURNAL_STREAM; stat -L -c '%n dev=%d ino=%i' /proc/self/fd/{0,1,2}"
if [[ $UID != 0 ]]; then
user="--user"
fi
unit=test-$(systemd-id128 new)
systemd-run $user --quiet --unit "$unit" --wait -G sh -c "$cmd"
systemd-run $user --quiet --unit "$unit" --wait -G --property=StandardOutput=journal --property=StandardError=journal sh -c "$cmd"
systemd-run $user --quiet --unit "$unit" --wait -G --property=StandardOutput=journal --property=StandardError=journal+console sh -c "$cmd"
systemd-run $user --quiet --unit "$unit" --wait -G --property=StandardOutput=journal+console --property=StandardError=journal sh -c "$cmd"
journalctl --sync || sleep 1
journalctl $user -o cat -u "$unit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment