[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cleaning /tmp regularly using bootclean.sh + crond



Hello all again.

So what do we do? What is the cron/multi-user safe way to clean up regularly /tmp ?

I checked the way bootclean.sh is implemented:

        if cd /tmp && [ "`find . -maxdepth 0 -perm -002`" = "." ]
          then
                # First remove all old files.
                find . -depth -xdev $TEXPR $EXCEPT \
                                ! -type d -print0 | xargs -0r rm -f
                # And then all empty directories.
                find . -depth -xdev $DEXPR $EXCEPT \
                                -type d -empty -exec rmdir \{\} \;
                rm -f .X*-lock
          fi


So, "find" doesn't follow symlinks by default right? Where is the risk in removing
other files outside /tmp by means of symlinks?

Man find says:
(...)
-P     Never  follow  symbolic links.  This is the default behaviour.  When find
examines or prints information a file, and the file is a symbolic link, the
information used shall be taken from the properties of  the  symbolic  link itself.

cheers
Josep SERRANO

>> Yes, tmpreaper does the job. But here I was preteding to simply reuse the
>> bootclean.sh by simply making a symlink. Why installing an addittional
>> package if you already have the stuff to the the job?
>>
>> Maybe I am wrong and it is a bad idea using bootclean.sh in crond ?
>
> Generally speaking, unless you know for sure, you don't want to assume
> something is cron-safe.
>




Reply to: