Skip to main contentClaim $5 in free credit — one-time, per account. Claim $5 free
Krova CloudKrova Cloud
Cloud Infrastructure

Deleted a Linux Log but Disk Space Stayed Full? Find the Open File

Deleted a log but Linux still reports a full disk? Find the open file, check its allocation and choose a documented recovery action before restarting.

RB
Rohit Bhadani5 min read
Share
Frosted-glass log file retained inside a turquoise loop linked to a process cube, illustrating a deleted file still held open.

Imagine you remove an oversized application log from a Linux server. The filename disappears, but df still shows almost no room. Deleting more files feels like the obvious next move. First, find out whether the application is still holding the old log open.

A deleted log can keep using disk space while a process has it open. Identify the file and its holders, then use the application’s documented log-reopen procedure or arrange a controlled restart. Don’t restart a service merely because its name appears beside a deleted file. Confirm that the file belongs to the full filesystem and has meaningful allocated space.

This guide follows that hypothetical situation on a self-managed Linux server, including a Krova Cube. It uses lsof, GNU stat and access to /proc. The commands inspect state; the example process and descriptor numbers must be replaced with fresh values from your server.

Removing the name doesn’t close the file

A pathname is how you find a file. An open file descriptor is how a running process continues using it. Removing the last directory link doesn’t take that descriptor away. Linux keeps an unlinked file available to its holders until the last referring descriptor closes. The unlink manual describes this lifetime.

That makes the missing filename a poor recovery check. The application may still write through its existing descriptor even though you can’t find the log at its former path. Red Hat documents this disk-space symptom, along with the risks of forcing changes to an in-use file.

Start with the filesystem you meant to clear

Use an existing parent directory of the deleted log. Here /var/log/my-app is a placeholder. df reports the filesystem containing its path argument; checking / alone can miss a separate log mount.

target=/var/log/my-app
df -h -- "$target"

Run the investigation in the environment that owns the workload. A container’s process IDs and mount view may differ from the host’s. A deleted file on a memory-backed filesystem doesn’t explain bytes consumed on your disk mount. Match the filesystem before planning an interruption. This path focuses on ordinary open file descriptors; memory-mapped files and filesystem-specific references can require a different investigation.

Find the holder, then narrow the investigation

If you already know the application’s current PID, inspect that process first. Replace 1234 below. +L1 selects open files with no remaining links; -a combines that selection with the PID filter. Without -a, selection options can broaden the result. These options are documented in the lsof manual.

pid=1234
lsof -nP -a -p "$pid" +L1

If the holder is unknown, an authorized system-wide inspection is an option. It can be expensive on a busy machine, and restricted visibility can omit processes. An empty result is therefore a clue, not proof that no open deleted file exists.

lsof -nP +L1

Look for a regular file (REG) on the affected device. Record its PID, DEVICE, NODE, numeric file descriptor and old name. SIZE/OFF can represent size or offset, so don’t simply add that column. Several rows can refer to the same file; a shared device-and-inode identity matters more than the number of rows.

Check allocation before estimating the payoff

For a fresh numeric descriptor such as 5w, use its numeric part, 5. Linux exposes descriptors through symbolic links under /proc/PID/fd. Access is permission-controlled. If the process exited or the descriptor changed, collect a new observation rather than working from stale numbers.

# Replace both numbers using a fresh lsof observation.
pid=1234
fd=5
stat --dereference \
  --format='type=%F device=%d inode=%i links=%h size=%s blocks=%b block_size=%B' \
  "/proc/$pid/fd/$fd"

GNU stat follows that link with --dereference. It reports apparent size with %s, allocated blocks with %b, and bytes per reported block with %B. Check file type, device, inode and zero link count against the fresh investigation. Device numbers may use different display formats across tools.

For an illustrative reading, blocks=4096 and block_size=512 describe 2,097,152 bytes of reported allocation. The apparent size could be much larger for a sparse file. Count a device/inode pair once, even if several processes hold it. This is an allocation clue, not a promise that closing one handle will increase df by exactly that amount.

Choose a release operation the application supports

Once you’ve identified a material file, map every relevant holder to its service. If the application documents a way to reopen logs, follow that procedure and verify the old handle disappears. Otherwise, plan a graceful restart around in-flight work, persistence and availability. A single-instance service may be interrupted. If another process still holds the file, restarting the first one may leave the allocation in place.

Don’t redirect output into /proc/PID/fd/FD or truncate an unidentified open file to reclaim space. A descriptor may refer to application state, and forced truncation can produce inconsistent behavior. A generic SIGHUP is also not a universal log-reopen instruction. Use the owning application’s documented procedure.

If the file is managed by Docker’s logging driver, use Krova’s Docker log-retention guide. Don’t delete or truncate those managed files as a routine cleanup. An application log inside a mounted directory needs its own retention policy.

Finish with two checks

After the planned action, repeat the open-file inspection and df against the same filesystem. Confirm the specific file is no longer held, then check that the service is healthy and writing useful logs again. Observe another normal workload interval: a quieter disk after a restart doesn’t establish that retention is fixed.

If the file is gone from the inspection but free space hasn’t improved, investigate other usage and filesystem-specific accounting. If bytes are available but new file creation fails, check inode availability. This procedure diagnoses one cause; it doesn’t account for every full-disk condition.

On Krova Cube, you control the Linux guest and have root access for this kind of investigation. That control also leaves the application’s log policy and recovery procedure with you. This guide concerns self-managed guest operations, rather than Nest’s managed hosting workflow.

Operate your Linux workload on Cube

Explore Cube’s self-managed Linux environment, then plan storage, log retention and a recovery procedure for your application.

Creation context: this article and its cover were produced with AI assistance using the linked documentation, checked on 16 November 2026 IST. The scenario and allocation example are hypothetical. These commands were not run against a customer workload; no hands-on result or human review is claimed.

For AI agents:llms.txtsitemap

Related posts