diff --git a/man/systemctl.xml b/man/systemctl.xml
index b1fb6cec8c..a966e3ea7a 100644
--- a/man/systemctl.xml
+++ b/man/systemctl.xml
@@ -2348,6 +2348,17 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err
+
+
+
+
+
+ Display unit log output while executing unit operations.
+
+
+
+
+
diff --git a/src/systemctl/systemctl-start-unit.c b/src/systemctl/systemctl-start-unit.c
index 7ea2cf8998..7e81afae00 100644
--- a/src/systemctl/systemctl-start-unit.c
+++ b/src/systemctl/systemctl-start-unit.c
@@ -10,6 +10,7 @@
#include "bus-util.h"
#include "bus-wait-for-jobs.h"
#include "bus-wait-for-units.h"
+#include "fork-journal.h"
#include "macro.h"
#include "special.h"
#include "string-util.h"
@@ -388,9 +389,13 @@ int verb_start(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to allocate unit watch context: %m");
}
+ _cleanup_(journal_terminate) PidRef journal_pid = PIDREF_NULL;
if (arg_marked)
ret = enqueue_marked_jobs(bus, w);
- else
+ else {
+ if (arg_verbose)
+ (void) journal_fork(arg_runtime_scope, (const char**) names, &journal_pid);
+
STRV_FOREACH(name, names) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -404,6 +409,7 @@ int verb_start(int argc, char *argv[], void *userdata) {
return log_oom();
}
}
+ }
if (!arg_no_block) {
const char *extra_args[4];
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index fdbde7dc5e..3c691c5dee 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -90,6 +90,7 @@ bool arg_show_types = false;
int arg_check_inhibitors = -1;
bool arg_dry_run = false;
bool arg_quiet = false;
+bool arg_verbose = false;
bool arg_no_warn = false;
bool arg_full = false;
bool arg_recursive = false;
@@ -304,6 +305,7 @@ static int systemctl_help(void) {
" suspend-then-hibernate, hybrid-sleep, default,\n"
" rescue, emergency, and exit.\n"
" -q --quiet Suppress output\n"
+ " -v --verbose Show unit logs while executing operation\n"
" --no-warn Suppress several warnings shown by default\n"
" --wait For (re)start, wait until service stopped again\n"
" For is-system-running, wait until startup is completed\n"
@@ -510,6 +512,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
{ "dry-run", no_argument, NULL, ARG_DRY_RUN },
{ "quiet", no_argument, NULL, 'q' },
+ { "verbose", no_argument, NULL, 'v' },
{ "no-warn", no_argument, NULL, ARG_NO_WARN },
{ "root", required_argument, NULL, ARG_ROOT },
{ "image", required_argument, NULL, ARG_IMAGE },
@@ -556,7 +559,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
/* We default to allowing interactive authorization only in systemctl (not in the legacy commands) */
arg_ask_password = true;
- while ((c = getopt_long(argc, argv, "hC:t:p:P:alqfs:H:M:n:o:iTr.::", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "hC:t:p:P:alqvfs:H:M:n:o:iTr.::", options, NULL)) >= 0)
switch (c) {
@@ -770,6 +773,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
+ case 'v':
+ arg_verbose = true;
+ break;
+
case 'f':
arg_force++;
break;
diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h
index 00405f4705..e282380323 100644
--- a/src/systemctl/systemctl.h
+++ b/src/systemctl/systemctl.h
@@ -68,6 +68,7 @@ extern bool arg_show_types;
extern int arg_check_inhibitors;
extern bool arg_dry_run;
extern bool arg_quiet;
+extern bool arg_verbose;
extern bool arg_no_warn;
extern bool arg_full;
extern bool arg_recursive;