SHELL SCRIPT TO MONITOR FILE GROWTH IN LINUX

Use this shell script to monitor the files in real time which grow suddenly in the filesystem in linux



while date;du -sh /data01/*|sort -hr|head -2;do sleep 1;done

I move a big file from one directory to another

[oracle@orcl19x apps01]$ mv database.tar /data01/

When i move the file, i run the script to find out if the file is listed in the output. You can see the sudden growth of database.tar file replace from base directory

[oracle@orcl19x ~]$ while date;du -sh /data01/*|sort -hr|head -2;do sleep 1;done


Thu Jul  1 00:20:55 IST 2021
11G     /data01/product
2.3G    /data01/base
Thu Jul  1 00:20:57 IST 2021
11G     /data01/product
2.3G    /data01/base
Thu Jul  1 00:20:58 IST 2021
11G     /data01/product
2.3G    /data01/base
Thu Jul  1 00:20:59 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:00 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:01 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:02 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:04 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:05 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:06 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:07 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:08 IST 2021
11G     /data01/product
2.3G    /data01/database.tar
Thu Jul  1 00:21:09 IST 2021
11G     /data01/product
2.4G    /data01/database.tar
Thu Jul  1 00:21:11 IST 2021
11G     /data01/product
2.4G    /data01/database.tar
Thu Jul  1 00:21:12 IST 2021
11G     /data01/product
2.4G    /data01/database.tar
Thu Jul  1 00:21:13 IST 2021
11G     /data01/product
2.5G    /data01/database.tar
Thu Jul  1 00:21:14 IST 2021
11G     /data01/product
2.5G    /data01/database.tar
Thu Jul  1 00:21:15 IST 2021
11G     /data01/product
2.5G    /data01/database.tar
Thu Jul  1 00:21:17 IST 2021
11G     /data01/product
2.5G    /data01/database.tar
Thu Jul  1 00:21:18 IST 2021
11G     /data01/product
2.8G    /data01/database.tar
Thu Jul  1 00:21:19 IST 2021
11G     /data01/product
2.8G    /data01/database.tar
Thu Jul  1 00:21:20 IST 2021
11G     /data01/product
2.8G    /data01/database.tar
Thu Jul  1 00:21:21 IST 2021
11G     /data01/product
2.8G    /data01/database.tar
Thu Jul  1 00:21:22 IST 2021
11G     /data01/product
2.8G    /data01/database.tar
Thu Jul  1 00:21:24 IST 2021
11G     /data01/product
2.8G    /data01/database.tar
Thu Jul  1 00:21:25 IST 2021
11G     /data01/product
2.8G    /data01/database.tar

Use this in crontab and redirect the output to a file to keep track of unknown culprit which fill the space in a short duration

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s