我有点困惑。 我有一个下载目录,我想用tmpreaper删除30天前的所有文件。 只是一个问题,有问题的目录是一个单独的分区与一个lost + found目录,当然我需要保留它,所以我加了--protect 'lost+found' ,问题是tmpreaper输出:
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'
我已经尝试了像丢失*等其他模式…我正在运行tmpreaper作为非root用户,因为没有超级用户权限的原因,因为我拥有所有文件(除了lost + found)。
我是否被迫以root身份运行tmpreaper? 还是我的shell技能不如我想象的那么好? 我猜问题是:
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.
任何想法和/或build议?
我试图运行的命令是类似的
$ /usr/sbin/tmpreaper -t --protect 'lost+found' 30d /mydir 1> /dev/null error: chdir() to directory `lost+found' (inode 11) failed: Permission denied
编辑:
Redmumba注意到,返回代码仍然是零,文件被删除。 我之前一定还有其他的问题,因为我写这篇文章的时候没有被删除。 无论如何它现在工作,谢谢。
lost+found目录是特定于文件系统的,即使您更改了权限,它们也会自动恢复为root:root重新挂载(甚至可能更早)。 但是,因为听起来你不想删除那里的东西,这听起来像是你指定的目录可能是一个问题。
例如,假设您正在删除位于单独分区上的/tmp内的文件。 如果运行tmpreaper --protect 'lost+found' /tmp/* ,它会将chdir放入/tmp/lost+found 然后应用shell glob – 但是会失败并显示权限问题。 当你指定tmpreaper的目录时,只需使用父目录 – 即tmpreaper --protect 'lost+found' /tmp 。
希望这是你的问题…如果没有,更新更多的信息(如你正在使用的确切命令),我们可以尝试让你回到正轨!
编辑:所以我把它设置在本地,我注意到它成功完成。 它似乎只打印出错误信息,但不会对它做出反应 – 即返回0,表示成功。 我原本以为这是失败的,但似乎并非如此。 这听起来像提交一个错误可能是为了细节,因为我不会想象这是预期的行为。