Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a little confused. I have a download directory that I want to remove all files older then 30 days with tmpreaper. Just one problem, the directory in question is a separate partition with a lost+found directory, of course I need to keep it so I added --protect 'lost+found', the problem is that tmpreaper outputs:

error: chdir() to directory 'lost+found' (inode 11) failed: Permission denied
(PID 30604) Back from recursing down `lost+found'.
Entry matching `--protect' pattern skipped. `lost+found'

I have tried with other pattern like lost* and so on... I'm running tmpreaper as a non-root user because there is no reason for superuser privileges because I own all files (except lost+found).

Are I'm forced to run tmpreaper as root? Or are my shell-skills not as good as I thought? I guess the problem is:

tmpreaper  will  chdir(2) into each of the directories you've 
specified for cleanup, and check for files matching the 
<shell_pattern> there.  It then builds a list of them,  and
uses that to protect them from removal.

Any thought and/or advice?

The command I'm trying to run is something like

$ /usr/sbin/tmpreaper -t --protect 'lost+found' 30d /mydir 1> /dev/null
error: chdir() to directory `lost+found' (inode 11) failed: Permission denied


Redmumba noticed that the return code is still zero, and the files are removed. I must have had some other issues before because nothing was removed when I wrote this post. Anyway it's working now, Thanks.

share|improve this question
up vote 0 down vote accepted

The lost+found directory is file system specific and, even if you change the permissions, they will automatically be reverted back to root:root on a remount (or possibly even sooner). However, because it sounds like you DON'T want to remove things there, it sounds like it may be a problem with the directory you're specifying.

For example, lets say you're removing the files inside /tmp, which is on a separate partition. If you run tmpreaper --protect 'lost+found' /tmp/*, it will chdir into /tmp/lost+found then apply the shell glob--but it will fail with the permissions issue you saw. When you specify the directory for tmpreaper, just use the parent directory--i.e., tmpreaper --protect 'lost+found' /tmp.

Hopefully that's your problem... if not, update with more information (such as the exact command you're using) and we can try and get you back on track!

EDIT: So I set it up locally, and I noticed that it finishes successfully. It appears that it only prints out the error message, but does not react to it--i.e., it returns 0, indicating success. I originally assumed it was failing, but that doesn't seem to be the case. It sounds like filing a bug might be in order with details, as I wouldn't imagine that this is intended behavior.

share|improve this answer
Yes, I don't want to remove anything from lost+found. I have updated the question with a example. – nsg Mar 20 '11 at 11:56
Hm, I updated my response; the command finishes correctly, but shouldn't be displaying an error message--especially since it even says that it matches the protect rule. – Andrew M. Mar 20 '11 at 22:58
Ah, you are correct. thanks for the help. – nsg Mar 21 '11 at 15:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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