Cleaning out /tmp on startup [cleanfs]

Anderson Lizardo lizardo at
Wed Mar 24 17:14:57 PST 2004

On Seg, 22 Mar 2004 15:13:13 -0700, Nathan Coulson wrote:
> cd /tmp; find . -xdev ! -name . ! \( -name lost+found -uid 0 \) -depth
> -exec rm -rf {} \; [With the help of Zack]

"! -name ." can be changed to "-mindepth 1". Also, I suggest use "&&"
after the cd command instead of semicolon. What happens if, for some
reason, the cd command fails? ;)

Also, "! -name lost+found" was used to avoid removing lost+found, but
the files inside it (lost inode contents, AFAIK) are still removed.
"-path" can be used instead to avoid this.

An alternative command (not tested) could be:

find /tmp -xdev -mindepth 1 ! -path '/tmp/lost+found*' -depth \
-exec rm -rf {} \;

Anderson Lizardo
lizardo at

More information about the blfs-dev mailing list