summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/systemd-run.xml12
-rw-r--r--src/run/run.c21
2 files changed, 26 insertions, 7 deletions
diff --git a/man/systemd-run.xml b/man/systemd-run.xml
index 5fb4ee28eb..f57c13b500 100644
--- a/man/systemd-run.xml
+++ b/man/systemd-run.xml
@@ -232,11 +232,21 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
<listitem><para>When invoking a command as service connects
its standard input and output to the invoking tty via a
pseudo TTY device. This allows invoking binaries as services
- that expect interactive user input, such as an interactive
+ that expect interactive user input, such as interactive
command shells.</para></listitem>
</varlistentry>
<varlistentry>
+ <term><option>--quiet</option></term>
+ <term><option>-q</option></term>
+
+ <listitem><para>Suppresses additional informational output
+ while running. This is particularly useful in combination with
+ <option>--pty</option> when it will suppress the initial
+ message explaining how to terminate the TTY connection.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><option>--on-active=</option></term>
<term><option>--on-boot=</option></term>
<term><option>--on-startup=</option></term>
diff --git a/src/run/run.c b/src/run/run.c
index 828aa5cf93..242bed0a43 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -59,6 +59,7 @@ static usec_t arg_on_unit_active = 0;
static usec_t arg_on_unit_inactive = 0;
static char *arg_on_calendar = NULL;
static char **arg_timer_property = NULL;
+static bool arg_quiet = false;
static void help(void) {
printf("%s [OPTIONS...] {COMMAND} [ARGS...]\n\n"
@@ -82,7 +83,8 @@ static void help(void) {
" --gid=GROUP Run as system group\n"
" --nice=NICE Nice level\n"
" --setenv=NAME=VALUE Set environment\n"
- " -t --pty Run service on pseudo tty\n\n"
+ " -t --pty Run service on pseudo tty\n"
+ " -q --quiet Suppress information messages during runtime\n\n"
"Timer options:\n\n"
" --on-active=SEC Run after seconds\n"
" --on-boot=SEC Run after seconds from machine was booted up\n"
@@ -144,6 +146,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "setenv", required_argument, NULL, ARG_SETENV },
{ "property", required_argument, NULL, 'p' },
{ "tty", no_argument, NULL, 't' },
+ { "quiet", no_argument, NULL, 'q' },
{ "on-active", required_argument, NULL, ARG_ON_ACTIVE },
{ "on-boot", required_argument, NULL, ARG_ON_BOOT },
{ "on-startup", required_argument, NULL, ARG_ON_STARTUP },
@@ -160,7 +163,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "+hrH:M:p:t", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "+hrH:M:p:tq", options, NULL)) >= 0)
switch (c) {
@@ -255,6 +258,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_pty = true;
break;
+ case 'q':
+ arg_quiet = true;
+ break;
+
case ARG_ON_ACTIVE:
r = parse_sec(optarg, &arg_on_active);
@@ -736,7 +743,8 @@ static int start_transient_service(
sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
- log_info("Running as unit %s.\nPress ^] three times within 1s to disconnect TTY.", service);
+ if (!arg_quiet)
+ log_info("Running as unit %s.\nPress ^] three times within 1s to disconnect TTY.", service);
r = pty_forward_new(event, master, false, &forward);
if (r < 0)
@@ -750,10 +758,10 @@ static int start_transient_service(
forward = pty_forward_free(forward);
- if (last_char != '\n')
+ if (!arg_quiet && last_char != '\n')
fputc('\n', stdout);
- } else
+ } else if (!arg_quiet)
log_info("Running as unit %s.", service);
return 0;
@@ -871,7 +879,8 @@ static int start_transient_scope(
if (!env)
return log_oom();
- log_info("Running as unit %s.", scope);
+ if (!arg_quiet)
+ log_info("Running as unit %s.", scope);
execvpe(argv[0], argv, env);