System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to list the files being modified now in a particular direcotory

SOLVED
Go to solution
Din_1
Frequent Advisor

How to list the files being modified now in a particular direcotory

Hi all,

Mine is HP-UX 11.23 IA64 server. I need to find the list of files, which is being modified currently in a particular direcotory.
Is there any command to get the output for this?

Regards,
Din
13 REPLIES
Johnson Punniyalingam
Honored Contributor

Re: How to list the files being modified now in a particular direcotory

ls -lrt
Problems are common to all, but attitude makes the difference
Johnson Punniyalingam
Honored Contributor

Re: How to list the files being modified now in a particular direcotory

lsof "man lsof"
Problems are common to all, but attitude makes the difference
Din_1
Frequent Advisor

Re: How to list the files being modified now in a particular direcotory

Hi Jhonson,

Thanks for your reply, I forgot to mention a point. I need to find the files in that directory along with that sub direcotories.

Thanks,
Din
James R. Ferguson
Acclaimed Contributor

Re: How to list the files being modified now in a particular direcotory

Hi Din:

Use 'find' and define what you mean when you say "modified currently". For example:

# cd

# find . -xdev -type f -mtime 0

...would list *files* in the current directory ('.') and not cross mountpoints ('-xdev') and list the names of the files modified during the last 24-hours ('-mtime 0').

If you want to find files modified *since* a time you can do:

# cd
# touch -mt 10250000 /var/tmp/myref
# find . -xdev -type f -newer /var/tmp/myref

...which would find all files modified after 0000 hours on October 25.

See the manpages for 'find' and 'touch' for more information.

Regards!

...JRF...
Din_1
Frequent Advisor

Re: How to list the files being modified now in a particular direcotory

Hi James,

Thanks for your reply. I have a file system called /testarch. This file system grows more than 85% frequently. So whenever this filesystem goes more than this benchmark i need to find the growing files under this direcotory and its subdirecotory.

Thanks,
Din
Johnson Punniyalingam
Honored Contributor

Re: How to list the files being modified now in a particular direcotory

ls -lRt

-R
lists subdirectories recursively.

-t
sorts entries by time. By default, this option sorts the output by the modification times of files.

Please help to man ls " you find more"

Rgds,
Johnson
Problems are common to all, but attitude makes the difference
Johnson Punniyalingam
Honored Contributor

Re: How to list the files being modified now in a particular direcotory

Hi Din,

the below command will help you find some large file under your mount point /testarch

find -xdev -type f -size +5000000c -exec ls -ld {} \; | sort -nk 5

after you find if you would like to house keep you can gzip / rm those files

schedule cron -job some thing like house keeping scripts

Rgds,
Johnson
Problems are common to all, but attitude makes the difference
Johnson Punniyalingam
Honored Contributor

Re: How to list the files being modified now in a particular direcotory

Hi Din,

One more thing you can automate "script" which will send File system email alert :)

bdf | awk 'z[split($5,z,"%")-1]>70' | elm -s "Filesystem > 70%" xxx@xxx.xxx

if you have mail service configured

Thanks,
Best Regards,
Johnson
Problems are common to all, but attitude makes the difference
Din_1
Frequent Advisor

Re: How to list the files being modified now in a particular direcotory

Hi Jhonson,

Thanks for your reply. To get the large size file in a particular directory i can use the following command.

find /testarch | xargs ll -ld | sort -nrk5 | more

My requirement now is, i need to find a file which is growing without any limits in a particular file system.

Let's assueme /var filesystem is about to reach 100%. I need to find a particular file which is causing this effect.

Let's assume /var/adm/file1 is growing without any limit. I need to find this file1, and stop this growing further to avoid 100% of filesystem.

Hope you got my point.

Regards,
Din
Johnson Punniyalingam
Honored Contributor

Re: How to list the files being modified now in a particular direcotory

Hi Din,

you requirement is very inresting i got your point ..?

usually suddenly file system grow's full we usally find some large file and purge them,

either one option in the File system settings disable "large File " disable /enable

Just an idea only
Problems are common to all, but attitude makes the difference
Dennis Handly
Acclaimed Contributor

Re: How to list the files being modified now in a particular direcotory

How frequently do you want to look?

You could do what JRF showed with his "find . -xdev -type f -newer /var/tmp/myref" solution. Just sort and put the output in a file:
find /testarch -xdev -type f -newer /var/tmp/myref -exec ll + | awk '{ print $9, $5 }' | sort > size_1

You then touch a new reference file. Then sleep.

Then you collect new info and use comm(1) to compare old with new. You can either report on any changes or something more complex with a X% growth.

Din_1
Frequent Advisor

Re: How to list the files being modified now in a particular direcotory

Hi Dennis,

To say clearly...

i need a output like what a
tail -f ( this is real time update )
command gives...

Like said above... i need output of realtime growing files...

Thanks,
Din
Dennis Handly
Acclaimed Contributor
Solution

Re: How to list the files being modified now in a particular direcotory

>I need output of realtime growing files...

You'll need to write a script based on the suggestions above.