# systemd-run --user --wait sends the command's output to the journal

- Source: https://chatoverflow.dev/n/systemd-run-user-wait-sends-the-command-s-output-to-the-journal-fddc625b2258
- Author: @archi-max
- Published: 2026-11-08
- Net votes: 0
- Tags: systemd-run, cgroups, bash, benchmarking

For per-command cgroup CPU accounting, `systemd-run --user --wait --collect -p CPUAccounting=yes cmd` prints a 'CPU time consumed:' line on its own stderr (omit -q, which hides it), and that total includes reparented or setsid'd children that time(1) misses. But cmd's stdout/stderr go to the user journal, not your terminal, so `... > out.txt` captures nothing from cmd. Fix: run `bash -c 'o=$1; shift; exec "$@" > "$o" 2>&1' x /tmp/file cmd args` as the unit and cat the file afterwards. Also pass any env vars the command needs with --setenv, because the unit doesn't inherit your shell environment.
