<term><option>--timeout=<replaceable>SECS</replaceable></option></term>
<listitem>
- <para>When used with the <command>call</command> command,
- specifies the maximum time to wait for method call
- completion. If no time unit is specified, assumes
- seconds. The usual other units are understood, too (ms, us,
- s, min, h, d, w, month, y). Note that this timeout does not
- apply if <option>--expect-reply=no</option> is used, as the
- tool does not wait for any reply message then. When not
- specified or when set to 0, the default of
- <literal>25s</literal> is assumed.</para>
+ <para>When used with the <command>call</command> command, specifies the maximum time to wait for
+ method call completion. When used with the <command>monitor</command> command, since version v257,
+ specifies the maximum time to wait for messages before automatically exiting. If no time unit is
+ specified, assumes seconds. The usual other units are understood, too (ms, us, s, min, h, d, w,
+ month, y). Note that this timeout does not apply if <option>--expect-reply=no</option> is used,
+ when combined with the <command>call</command> command, as the tool does not wait for any reply
+ message then. When not specified or when set to 0, the default of <literal>25s</literal> is
+ assumed for the <command>call</command> command, and it is disabled for the
+ <command>monitor</command> command.</para>
<xi:include href="version-info.xml" xpointer="v218"/>
</listitem>
'--expect-reply=[Expect a method call reply]:boolean:(1 0)' \
'--auto-start=[Auto-start destination service]:boolean:(1 0)' \
'--allow-interactive-authorization=[Allow interactive authorization for operation]:boolean:(1 0)' \
- '--timeout=[Maximum time to wait for method call completion]:timeout (seconds)' \
+ '--timeout=[Maximum time to wait for method call completion and monitoring]:timeout (seconds)' \
'--augment-creds=[Extend credential data with data read from /proc/$PID]:boolean:(1 0)' \
'*::busctl command:_busctl_commands'
if (r > 0)
continue;
- r = sd_bus_wait(bus, UINT64_MAX);
+ r = sd_bus_wait(bus, arg_timeout > 0 ? arg_timeout : UINT64_MAX);
+ if (r == 0 && arg_timeout > 0) {
+ if (!arg_quiet && arg_json_format_flags == SD_JSON_FORMAT_OFF)
+ log_info("Timed out waiting for messages, exiting.");
+ return 0;
+ }
if (r < 0)
return log_error_errno(r, "Failed to wait for bus: %m");
}