]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: stop showing last message from previous run
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Nov 2025 12:06:47 +0000 (13:06 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Nov 2025 19:03:00 +0000 (20:03 +0100)
--lines=1 means that we show the last message about the unit, whatever it is:

$ SYSTEMD_LOG_LEVEL=debug systemctl --verbose start demo2
...
Invoking 'journalctl -q --follow --no-pager --lines=1 --synchronize-on-exit=yes --unit=demo2.service' as child.
...
Directory /var/log/journal/7d16833bfa924410851e2a193bcfd4ba added.
Journal effective settings seal=no keyed_hash=yes compress=ZSTD compress_threshold_bytes=8B
...
Reiterating files to get inotify watches established.
Considering root directory '/run/log/journal'.
Considering root directory '/var/log/journal'.
Considering directory '/var/log/journal/7d16833bfa924410851e2a193bcfd4ba'.
Nov 26 17:24:35 rawhide systemd[1]: Finished demo2.service.
...
Executing dbus call org.freedesktop.systemd1.Manager StartUnit(demo2.service, replace)
...
Job for demo2.service finished.
Got result done/Success for job demo2.service.
journal: Sending message: {"method":"io.systemd.Journal.Synchronize","parameters":{"offline":false}}
Nov 27 13:05:30 rawhide systemd[1]: Starting demo2.service...
Nov 27 13:05:30 rawhide systemd[1]: demo2.service: Deactivated successfully.
Nov 27 13:05:30 rawhide systemd[1]: Finished demo2.service.
...

We obviously should only show _new_ messages, hence change to --lines=0.
This works properly after the fix in the previous commit.

Fixes #39048.

src/shared/fork-notify.c

index 624ddab8d15973fee932a86e9860e1f4cc9c60bf..cf014c25930ce46a4b496b5922774402fb55d4df 100644 (file)
@@ -219,7 +219,7 @@ int journal_fork(RuntimeScope scope, char * const* units, PidRef *ret_pidref) {
                         "-q",
                         "--follow",
                         "--no-pager",
-                        "--lines=1",
+                        "--lines=0",
                         "--synchronize-on-exit=yes");
         if (!argv)
                 return log_oom_debug();