« Back to Systemd: Frequently Asked Questions

How to see memory usage of a service with systemctl?

This article has last been updated at .

How to see memory usage of a service with systemctl?

Run systemctl with the 'show' subcommand and select the MemoryCurrent property, followed by the service.

systemctl show --property=MemoryCurrent nginx.service

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.

Usage

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
             └─override.conf
     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}'
2752512

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

Other questions related to Systemd

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.