smint
smint

Reputation: 263

Tool which shows me which files are written in Linux?

I found in IOStat, that some part of my application is writing extensively, but I don't know which process it is and what files it is writing to. In Vista there is a tool fo that which shows the files that have been active in the last 30 Seconds. Is there something similar for Linux?

Upvotes: 14

Views: 24383

Answers (7)

PiedPiper
PiedPiper

Reputation: 5785

strace -e trace=file -- <command>

will show you exactly what files your application is reading and writong

Upvotes: 9

leszek.hanusz
leszek.hanusz

Reputation: 5317

If you want to see all the file accesses in real time (up to 32 processes) you can use this command:

strace -f -e trace=file `ps aux | tail -n +2 | awk '{ORS=" "; print $2}' | sed -e 's/\([0-9]*\)/\-p \1 /g' | sed -e 's/\-p  $//g'` 

Upvotes: 8

Ludwig Weinzierl
Ludwig Weinzierl

Reputation: 16614

What you are looking for is lsof. It's a command line tool but there is also a GUI for it at sourceforge.

Upvotes: 2

ennuikiller
ennuikiller

Reputation: 46965

lsof will list all open files for a given process:

lsof -p

Upvotes: 3

Martin v. L&#246;wis
Martin v. L&#246;wis

Reputation: 127447

Linux provides a file change notification API called "dnotify", along with a command line utility dnotify. You can use that to keep track of the changes over the last 30s.

I would probably write an application that builds directly on the Linux API, and discards all events older than 30s.

Upvotes: 1

cakeforcerberus
cakeforcerberus

Reputation: 4657

Not sure of a program but the find command in utility has a lot of options which will allow you to find files and/or directories that have been modified within a certain time period.

For example:

$ find /home/you -iname "*.txt" -mtime -1 -print

Would find text files that were last modified 1 days ago.

You could wrap this call in some sort of script or write your own quick little app to use the results.

Here's a site with some more info and examples:

http://www.cyberciti.biz/faq/howto-finding-files-by-date/

Upvotes: 2

Finer Recliner
Finer Recliner

Reputation: 1597

To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:

find /directory_path -mtime -1 -print

more at:

http://www.mydigitallife.info/2006/01/19/find-files-that-are-modified-today-or-since-certain-time-ago-in-unix/

Upvotes: 3

Related Questions