← 返回命令列表

Linux command

systemd-socket-activate 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Listen on a port

systemd-socket-activate -l [8080] [command]

Listen on multiple

systemd-socket-activate -l [8080] -l [8081] [command]

Accept connections

systemd-socket-activate -l [8080] -a [command]

Use datagram (UDP)

systemd-socket-activate -l [8080] -d [command]

Set environment variables

systemd-socket-activate -l [8080] -E [VAR=value] [command]

Run in inetd

systemd-socket-activate -l [8080] --inetd [command]

说明

systemd-socket-activate is a test and development tool for socket activation. It listens on sockets and launches a specified command when connections arrive, simulating systemd's socket activation feature without needing to configure full socket and service unit files. By default it listens on a stream (TCP) socket. Use --datagram for UDP or --seqpacket for sequential packet sockets. The activated program receives the socket file descriptors via the $LISTEN_FDS protocol (or via stdin/stdout in --inetd mode).

参数

-l _ADDRESS_, --listen=_ADDRESS_
Listen on the specified address (port number or host:port).
-a, --accept
Launch a new instance of the command for each connection. Cannot be combined with --now.
-d, --datagram
Listen on a datagram socket (SOCK_DGRAM) instead of a stream socket. Cannot be combined with --seqpacket.
--seqpacket
Listen on a sequential packet socket (SOCK_SEQPACKET) instead of a stream socket. Cannot be combined with --datagram.
-E _VAR=VALUE_, --setenv=_VAR=VALUE_
Set an environment variable for the launched process. If no value given, inherits from the current environment.
--fdname=_NAME:NAME..._
Specify names for the file descriptors passed. Enables use of sd_listen_fds_with_names(3).
--inetd
Use the inetd protocol for passing file descriptors (as stdin/stdout) instead of the $LISTEN_FDS protocol.
--now
Start the command immediately instead of waiting for a connection. Cannot be combined with --accept.
-h, --help
Display help information.
--version
Display version information.

FAQ

What is the systemd-socket-activate command used for?

systemd-socket-activate is a test and development tool for socket activation. It listens on sockets and launches a specified command when connections arrive, simulating systemd's socket activation feature without needing to configure full socket and service unit files. By default it listens on a stream (TCP) socket. Use --datagram for UDP or --seqpacket for sequential packet sockets. The activated program receives the socket file descriptors via the $LISTEN_FDS protocol (or via stdin/stdout in --inetd mode).

How do I run a basic systemd-socket-activate example?

Run `systemd-socket-activate -l [8080] [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -l _ADDRESS_, --listen=_ADDRESS_ do in systemd-socket-activate?

Listen on the specified address (port number or host:port).