3

I'm working on a document management application on LAMP/php that lets you add and delete PDFs to our server. It works great, except for one nagging issue - the files you upload Monday might be gone Tuesday, and I can't diagnose why. it seems like the entire directory is getting deleted - my suspicion is that somewhere an incomplete string is getting passed to an unlink or something, but I've disabled every line of code I can find that removes files from the server and I'm still having trouble. How do I go about diagnosing the cause of these random disappearing files? Are there any utilities I can use to log any attempted removal of or changes to a file or directory?

8

1 Answer 1

1

idealy you'd want to find your bug...

find codebase/ -type f -exec grep -il "unlink" '{}' \;

alertativley if you want a hacky fix, update your apache user to have a umask that would enable it to create files, but not delete them...

sed -i 's/^\(start|[a-z|-]*)\)/\1\n    umask 0222/' `which apachectl`

also this would generate permission dennied errors in the error log...

2
  • find codebase/ -type f | xargs grep -sl "unlink " is easier to remember ... just my 3.14 cents.
    – specializt
    Commented Jan 23, 2013 at 22:18
  • @Michael would you mind explaining what the find command does and how it will help solve the problem asked.
    – crafter
    Commented Aug 30, 2015 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.