Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use 'find' to locate corrupted files UNIX
I had a problem. When I tried to Sync with my .Mac account, it would give me an error message. I found a log file in ~/Library/Logs/Sync called dotmacsync.log that said that some archive was corrupted, but it did not give me a path. So I waited for a while and then did this (from the Terminal) from my home directory:
 $ find . ! -type d -amin -1 -print 2> /dev/null > /tmp/F
/tmp/F will be empty if the machine has been idle for a while. Now I went through the process to produce the error message and redid the command. The command finds all files which are not directories which have been accessed within the past minute. After the second find, /tmp/F had about five files in it. A few were plist files that seemed to be trashed. I created a folder called ~/OLD and moved all the files listed in /tmp/F there. They were pref files and a few files used for sync. I didn't know which one was bad, so I just moved all of them.

In my case, the sync process was clobbering my Keychain. So I had to do "Keychain First Aid" on my keychain to make it OK again. Then I re-did the sync with my .Mac account. At this point, since a lot of the prefs were gone, the sync process thought this was my first time to sync. This gave me the option to replace what was on my machine with what was on my .Mac account. I did that, and now my Keychain and my sync process all seem to be in good shape.

But, really the point of this article is the find comnand mentioned above. It can be used to find what files are being accessed during a particular process to narrow down those that may be corrupted. Good luck!
    •    
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[15,691 views]  

Use 'find' to locate corrupted files | 8 comments | Create New Account
Click here to return to the 'Use 'find' to locate corrupted files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use 'find' to locate corrupted files
Authored by: stewby on Oct 05, '05 08:19:01AM

You can also do this more directly just by running
sudo fs_usage -f filesys
which will show you all filesystem access that happens while it's being run.



[ Reply to This | # ]
Use 'find' to locate corrupted files
Authored by: bdog on Oct 05, '05 06:23:28PM

fseventer is a very handy app.

http://www.macs.hw.ac.uk/~rpointon/osx/fseventer.html



[ Reply to This | # ]
Use 'find' to locate corrupted files
Authored by: johnsawyercjs on Oct 07, '05 03:16:17PM

When I try

$ find . ! -type d -amin -1 -print 2> /dev/null > /tmp/F

...Terminal responds with "Ambiguous output redirect". Any ideas as to what exactly to enter?



[ Reply to This | # ]
Use 'find' to locate corrupted files
Authored by: sjk on Oct 07, '05 03:55:54PM

Sounds like you're using tcsh. Try running it in bash.



[ Reply to This | # ]
Use 'find' to locate corrupted files
Authored by: johnsawyercjs on Oct 08, '05 12:59:10PM

You're right--tcsh is the default. I changed it to bash by entering 'sudo bash', which brought up the 'root#' prompt. Then I entered

$ find . ! -type d -amin -1 -print 2> /dev/null > /tmp/F

several times again, but got nothing--just another root# prompt every time, even though I opened several files and applications just before entering the command string.



[ Reply to This | # ]
Use 'find' to locate corrupted files
Authored by: ChaChi on Oct 08, '05 03:20:42PM

I must've replied to the wrong thread. See my comments below jonsaw.



[ Reply to This | # ]
Use 'find' to locate corrupted files
Authored by: sjk on Oct 09, '05 03:52:48PM

Any output will be in the /tmp/F file. To display it in the current window just remove the "> /tmp/F" redirection from the end of the command line.

Friendly reminder:

Running shell commands as root without understanding what they do puts your system at risk of accidental, unintended side effects or damage. A botched "find" command can be particularly hazardous when it encounters and affects many files.

The example in this hint is benign that way, except you want to be careful with the '>' redirection not writing output to the wrong file(s).



[ Reply to This | # ]
Use 'find' to locate corrupted files
Authored by: ChaChi on Oct 08, '05 03:18:13PM
Hi jonsaw, Seems to me like you are typing the $ at the beginning of the command ? If that's what you are doing try removing it like this:
find . ! -type d -amin -1 -print 2> /dev/null > /tmp/F


[ Reply to This | # ]