I have a requirement where I have to find some core/log files which are growing continuously and eating up my disk space in one of the production server. Now my job is to find them  and delete some of them which are not required. For this we have to follow below procedure to get the files which are growing now.

Logic : We will create a empty file using touch command. We will use find command to see all the files which are newer than file which we just created and then delete the files which are not required much.

Step1 : Create an empty file in any location, but prefered location is your home directory

#touch /root/testfile

Step2 : Find all the files which are newer than this file

#find / -newer /root/testfile -exec ls -lh {} ;

The above command will search entire server(/) for newer files(-newer) which are created/accessed after /root/testfile then list(ls -lh) in human readable.

For more meaning fullness you can exclude some of the system folders such as proc as shown below

find / ( -name proc -prune ) -o -newer /root/testfile -exec ls -lh {} ;

Even more meaning full way.  As the file is still growing in size you can filter it out using -size command. Suppose you want to list all the growing files which are more then some size(Here in my example it’s 300KB) you can use below command which will list files which are growing and whose size is more than 300KB.
find / ( -name proc -prune ) -o -newer test -size +300k -exec ls -lh {} ;

Once you find the files you can delete or move to other server where you have more space.

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.