Ops wants to limit a noisy batch service to 2 CPUs and 4 GB RAM on a shared host. How?
IntermediateScenarioProcesses, services and systemd
Answer
Situation read → cgroup v2 limits via systemd.
What I'd do →
sudo systemctl set-property batch.service CPUQuota=200% MemoryMax=4G MemoryHigh=3.5G
systemctl show batch -p CPUQuotaPerSecUSec -p MemoryMax
systemd-cgtop
For ad-hoc jobs: systemd-run --scope -p CPUQuota=100% -p MemoryMax=2G ./job.sh.
Why → CPUQuota=200% equals two full CPUs; MemoryHigh throttles before MemoryMax triggers the OOM killer.
Interview tip → set-property persists by writing a drop-in; add --runtime for a temporary change.
More on Processes, services and systemd
Your team has a Python API that someone starts with `nohup python app.py &`. Make it a proper service running as a non-root user.BeginnerThe service you created must bind to port 443, but it runs as a non-root user. How?BeginnerYou need to change one setting (memory limit) in a vendor-supplied unit file without editing it. How?BeginnerA service depends on a database on the same host and fails at boot because the DB isn't ready. How do you fix the ordering?IntermediateA service keeps crashing and systemd stops restarting it after a few attempts. How do you tune this?IntermediateA long-running app must reload its config without dropping connections. How do you wire this into systemd?Intermediate