# phpman > man > systemd-socket-activate(1)

> **TLDR:** Socket activation for systemd services.
>
- Activate a service when a specific socket is connected:
  `systemd-socket-activate {{path/to/socket.service}}`
- Activate multiple sockets for a service:
  `systemd-socket-activate {{path/to/socket1.service}} {{path/to/socket2.service}}`
- Pass environment variables to the service being activated:
  `{{SYSTEMD_SOCKET_ACTIVATION=1}} systemd-socket-activate {{path/to/socket.service}}`
- Activate a service along with a notification socket:
  `systemd-socket-activate {{path/to/socket.socket}} {{path/to/service.service}}`
- Activate a service with a specified port:
  `systemd-socket-activate {{path/to/socket.service}} {{-l|--listen}} {{8080}}`

*Source: tldr-pages*

---

[SYSTEMD-SOCKET-ACTIVATE(1)](https://www.chedong.com/phpMan.php/man/SYSTEMD-SOCKET-ACTIVATE/1/markdown)             systemd-socket-activate            [SYSTEMD-SOCKET-ACTIVATE(1)](https://www.chedong.com/phpMan.php/man/SYSTEMD-SOCKET-ACTIVATE/1/markdown)



## NAME
       systemd-socket-activate - Test socket activation of daemons

## SYNOPSIS
       **systemd-socket-activate** [OPTIONS...] _daemon_ [OPTIONS...]

## DESCRIPTION
       **systemd-socket-activate** may be used to launch a socket-activated service program from the
       command line for testing purposes. It may also be used to launch individual instances of the
       service program per connection.

       The daemon to launch and its options should be specified after options intended for
       **systemd-socket-activate**.

       If the **--inetd** option is given, the socket file descriptor will be used as the standard input
       and output of the launched process. Otherwise, standard input and output will be inherited,
       and sockets will be passed through file descriptors 3 and higher. Sockets passed through
       _$LISTEN_FDS_ to **systemd-socket-activate** will be passed through to the daemon, in the original
       positions. Other sockets specified with **--listen=** will use consecutive descriptors. By
       default, **systemd-socket-activate** listens on a stream socket, use **--datagram** and **--seqpacket**
       to listen on datagram or sequential packet sockets instead (see below).

## OPTIONS
### -l --listen=
           Listen on this _address_. Takes a string like "2000" or "127.0.0.1:2001".

### -a --accept
           Launch an instance of the service program for each connection and pass the connection
           socket.

### -d --datagram
           Listen on a datagram socket (**SOCK**___**DGRAM**), instead of a stream socket (**SOCK**___**STREAM**). May
           not be combined with **--seqpacket**.

### --seqpacket
           Listen on a sequential packet socket (**SOCK**___**SEQPACKET**), instead of a stream socket
           (**SOCK**___**STREAM**). May not be combined with **--datagram**.

### --inetd
           Use the inetd protocol for passing file descriptors, i.e. as standard input and standard
           output, instead of the new-style protocol for passing file descriptors using _$LISTEN_FDS_
           (see above).

### -E --setenv=
           Add this variable to the environment of the launched process. If _VAR_ is followed by "=",
           assume that it is a variable–value pair. Otherwise, obtain the value from the environment
           of **systemd-socket-activate** itself.

       **--fdname=**_NAME_[:_NAME_...]
           Specify names for the file descriptors passed. This is equivalent to setting
           _FileDescriptorName=_ in socket unit files, and enables use of **sd**___**listen**___**fds**___**with**___**[names**(3)](https://www.chedong.com/phpMan.php/man/names/3/markdown).
           Multiple entries may be specifies using separate options or by separating names with
           colons (":") in one option. In case more names are given than descriptors, superfluous
           ones will be ignored. In case less names are given than descriptors, the remaining file
           descriptors will be unnamed.

### -h --help
           Print a short help text and exit.

### --version
           Print a short version string and exit.

## ENVIRONMENT VARIABLES
       _$LISTEN_FDS_, _$LISTEN_PID_, _$LISTEN_FDNAMES_
           See **sd**___**listen**___**[fds**(3)](https://www.chedong.com/phpMan.php/man/fds/3/markdown).

       _$SYSTEMD_LOG_TARGET_, _$SYSTEMD_LOG_LEVEL_, _$SYSTEMD_LOG_TIME_, _$SYSTEMD_LOG_COLOR_,
       _$SYSTEMD_LOG_LOCATION_
           Same as in [**systemd**(1)](https://www.chedong.com/phpMan.php/man/systemd/1/markdown).

## EXAMPLES
### Example 1. Run an echo server on port 2000

           $ systemd-socket-activate -l 2000 --inetd -a cat

### Example 2. Run a socket-activated instance of [systemd-journal-gatewayd(8)](https://www.chedong.com/phpMan.php/man/systemd-journal-gatewayd/8/markdown)

           $ systemd-socket-activate -l 19531 /lib/systemd/systemd-journal-gatewayd

## SEE ALSO
       [**systemd**(1)](https://www.chedong.com/phpMan.php/man/systemd/1/markdown), [**systemd.socket**(5)](https://www.chedong.com/phpMan.php/man/systemd.socket/5/markdown), [**systemd.service**(5)](https://www.chedong.com/phpMan.php/man/systemd.service/5/markdown), [**systemd-run**(1)](https://www.chedong.com/phpMan.php/man/systemd-run/1/markdown), **sd**___**listen**___**[fds**(3)](https://www.chedong.com/phpMan.php/man/fds/3/markdown),
       **sd**___**listen**___**fds**___**with**___**[names**(3)](https://www.chedong.com/phpMan.php/man/names/3/markdown), [**cat**(1)](https://www.chedong.com/phpMan.php/man/cat/1/markdown)



systemd 249                                                               [SYSTEMD-SOCKET-ACTIVATE(1)](https://www.chedong.com/phpMan.php/man/SYSTEMD-SOCKET-ACTIVATE/1/markdown)
