Using the linux commands below you can find files on a system with limited free space. In the below example you will find “/dev/mapper/VolGroup00-LogVol00” has 4% available space.

[root@centos ~]$ df -h

Filesystem                         Size   Used   Avail   Use%
/dev/mapper/VolGroup00-LogVol00    14G    13G    548M    96%

The “VolGroup00-LogVol00” is a directory mapped as a volume used for logging. If you do not know where the logs are you can use the below command to find the large directories. You can also use a larger depth setting but the output will quickly become too much to show on the screen. As you can see below the /usr directory is 11 GB in size.

[root@centos ~]$ du -h --max-depth=1
8.0K ./mnt
541M ./lib
8.0K ./srv
52M ./etc
36M ./sbin
35M ./boot
84K ./tmp
7.9M./bin
26M ./tftpboot
0 ./proc
0 ./sys
68K ./home
0 ./misc
5.9M./opt
11G ./usr
8.0K./selinux
0 ./net
241M ./var
8.0K ./media
28M ./lib64
76K ./dev
12G .

The space consumed is very often log files used by a service. In this example a service created one log file per day and no cron jobs were setup to clear the logs. Once it is determined where the logs are located use the below command to clear out logs files older than 100 days where part of the log names began with the word “server”.

[root@centos ~]$ find /usr/local/service/logs/server* -mtime +100 -exec rm {} ;

If you find there is one long contiguous log instead of many individual logs you can truncate it. First rename the log file.

[root@centos ~]$ mv service.log service.log.old

Now, copy the last 100 lines of the log to a new log file.

[root@centos ~]$ tail -n 100 service.log.old > services.log

If you find the log was fed from the head instead of the tail you would copy the first 100 lines instead of the last 100 using the command below.

[root@centos ~]$ head -n 100 service.log.old > services.log

Next review the new log to ensure the events are recent.

[root@centos ~]$ cat service.log | less

If it looks good remove the old log.

[root@centos ~]$ rm services.log.old

Finally confirm free space has been recovered using the below command once more.

[root@centos ~]$ df -h

Filesystem                         Size   Used   Avail   Use%
/dev/mapper/VolGroup00-LogVol00    14G    6.06G  7.06G   47%
Categories: CentOSLinux

Related Posts

Application Containers

Docker container management using Rancher

What is container management and why to use it? A container management platform is a solution used to o create cloud-native, distributed applications and package legacy applications that were not originally designed for virtual environments. Read more…

CentOS

Install MySQL Galera Cluster on Centos 7

What is MySQL cluster and how to use it? MySQL Galera Cluster is a synchronous multi-master cluster, available on Linux only, and only supports the XtraDB/InnoDB storage engines . It is designed to provide high Read more…

Application Containers

Installing Docker on Centos 7

What are Docker containers and how to use them? Docker is a software technology providing containers. Docker provides an additional layer of abstraction and automation of operating-system-level virtualization on Windows and Linux. Docker uses the Read more…