Skip to content

journalctl --user --unit and --user-unit differ #26742

@smopucilowski

Description

@smopucilowski

systemd version the issue has been seen with

systemd 253 (253) +PAM -AUDIT -SELINUX -APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL -ACL +BLKID -CURL -ELFUTILS -FIDO2 +IDN2 -IDN -IPTC +KMOD -LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT -QRENCODE -TPM2 -BZIP2 +LZ4 -XZ -ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified

Used distribution

Gentoo

Linux kernel version used

6.1.12-gentoo

CPU architectures issue was seen on

x86_64

Component

journalctl

Expected behaviour you didn't see

I have a backup script that invokes rsync using systemd-run:

systemd-run \
        --user \
        --collect \
        --pty \
        --quiet \
        --wait \
        --property=ExitType=cgroup \
        --property=IOSchedulingClass=idle \
        --slice backup \
        --unit "backup" \
        rsync -aPh $args $src $dst

When inspecting the journal naively, I can see the journal entries for the invocation (ignore the ctrl-C aborts):

# journalctl -b -g backup
Mar 10 12:36:07 wanderweg.smoddom.local systemd[709036]: Created slice backup.slice.
Mar 10 12:36:07 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:37:09 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 2.408s CPU time.
Mar 10 12:37:09 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:41:00 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=23/n/a
Mar 10 12:41:00 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:41:00 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 52.683s CPU time.
Mar 10 12:41:00 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:43:25 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=23/n/a
Mar 10 12:43:25 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:43:25 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 5.110s CPU time.
Mar 10 12:44:08 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:44:08 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:47:19 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=23/n/a
Mar 10 12:47:19 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:47:19 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 46.194s CPU time.
Mar 10 12:47:19 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:47:24 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=23/n/a
Mar 10 12:47:24 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:47:24 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 1.815s CPU time.
Mar 10 12:48:32 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:48:34 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=20/n/a
Mar 10 12:48:35 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:48:35 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:48:36 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=20/n/a
Mar 10 12:48:36 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:48:36 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 1.048s CPU time.
Mar 10 12:48:36 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:48:37 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=20/n/a
Mar 10 12:48:37 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:50:38 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:50:51 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 2.360s CPU time.
Mar 10 12:50:51 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:53:27 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 56.583s CPU time.
Mar 10 12:53:27 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 13:06:42 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 4min 32.738s CPU time.

When trying to view the journal entries directly, they do not appear:

# journalctl -b --unit backup
-- No entries --
# journalctl -b --user --unit backup
No journal files were found.
-- No entries --

The desired entries only appear when using --user-unit, which the documentation appears to suggest is equivalent to --user --unit:

# journalctl -b --user-unit backup
Mar 10 12:36:07 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:37:09 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 2.408s CPU time.
Mar 10 12:37:09 wanderweg.smoddom.local systemd[709036]: Started backup.service.
Mar 10 12:41:00 wanderweg.smoddom.local systemd[709036]: backup.service: Main process exited, code=exited, status=23/n/a
Mar 10 12:41:00 wanderweg.smoddom.local systemd[709036]: backup.service: Failed with result 'exit-code'.
Mar 10 12:41:00 wanderweg.smoddom.local systemd[709036]: backup.service: Consumed 52.683s CPU time.
etc
  1. It is not clear from journalctl -b -g backup which are entries from the user journal vs the system journal, leaving a lot of puzzled confusion on viewing relevant journal entries, and
  2. It appears that --user --unit and --user-unit are different and not working as expected.

Possibly related to bug #23679

Unexpected behaviour you saw

As above.

Steps to reproduce the problem

As above.

Additional program output to the terminal or log subsystem illustrating the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Programming errors, that need preferential fixingjournal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions