« Back to Systemd: Frequently Asked Questions

How to see memory usage of a service with systemctl?

The systemctl command has multiple options to show the memory usage. With the status subcommand followed by the service, it will show the basics, including memory usage.

To retrieve the information that easier to parse, then use show followed by --property=MemoryCurrent and the service name.


The status output will include memory usage.

systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/nginx.service.d
     Active: active (running) since Mon 2024-06-17 17:59:45 UTC; 3h 54min ago
       Docs: man:nginx(8)
   Main PID: 36971 (nginx)
      Tasks: 2 (limit: 1012)
     Memory: 2.6M
        CPU: 26ms
     CGroup: /system.slice/nginx.service
             ├─36971 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             └─36972 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

For pulling in the information that can be parsed or scripted, consider retrieving the actual property from a running service.

# systemctl show --property=MemoryCurrent nginx.service | awk -F= '{print $2}'

Learn more about systemctl

This article uses the systemctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: systemctl

systemctl cheat sheet

Other questions related to systemd


Is the described answer not working or incorrect, got another tip or question? Share your thoughts!