Linux Labs

Inside the system: resources, kernel, processes / Stage 4 of 12

ulimit and sysctl: system ceilings

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 10 · on a machine · 4 min

The shipper loses logs

What you will learn

  • Find a process's open-file limit in /proc/<PID>/limits and tell the soft limit from the hard one.
  • Raise a service's limit with a LimitNOFILE line in a drop-in so that it survives a restart and a package update.
  • Read and change kernel parameters with sysctl and make them stick with a file in /etc/sysctl.d.

The lab-shipper log collector forwards the logs of a hundred shop services from /var/log/shop to a central store. Your colleagues only see the logs of some of the services. Look at what the shipper itself writes, at your own open-file limit and at how many files the shipper has open.

Exercise · look

Look at the shipper

The lab-shipper collector forwards the logs from /var/log/shop. Look at the last lines of its log, at your own open-file limit and at how many files the shipper process has open.

First, predict

The shipper cannot open the next log: Too many open files. How many files does the shipper process already have open?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

The shipper process has 64 files open and cannot open the next one. Your ulimit -n is 1024. What follows from this?

  • Linux does not forbid opening a file that another process has open: a service writes a log while the shipper reads it. A refused access would look like Permission denied.

  • The logs are already on the disk; the shipper only reads them. df -h shows a lack of space, and the error would read No space left on device.

  • Then other programs could not open files either, yet you open them freely. The shipper stops at exactly 64 — that is its own ceiling.

The shipper process has its own ceiling — 64 open files, which is lower than yours.

Ubuntu 24.04
Loading…