Interview Prep/Linux/Processes, services and systemd

A service should only start when a request arrives on its port, to save memory. How?

AdvancedScenarioProcesses, services and systemd
Answer

Situation read → Socket activation.

What I'd do →

  1. /etc/systemd/system/tool.socket:
[Socket]
ListenStream=9000

[Install]
WantedBy=sockets.target
  1. tool.service with ExecStart=/usr/local/bin/tool and the app reading the inherited socket (LISTEN_FDS).
  2. systemctl enable --now tool.socket.

Why → systemd holds the port; the first connection starts the service, and no connection is lost during startup.

Interview tip → The app must support receiving the socket from systemd; not every app does.

All Linux questions Roadmap: Linux

More on Processes, services and systemd