Re: Annoying tmp files on shared host

Ken Brush <[email protected]>
Newsgroups gmane.org.user-groups.linux.pdxlug
Message-ID <[email protected]>
On Wednesday 08 September 2004 09:00 pm, Cliff Wells wrote:
> On Sat, 2004-08-28 at 10:01, Chris Martin wrote:
> > I host a site on a shared server that, recently, is constantly sending
> > me emails about running out of space. This account is a small (100MB)
> > account, and when I go into cPanel and look at the disk usage,
> > /tmp/urchin is usually the culprit (most of the time > 75MB).
> > I cleared them out Wed, and by yesterday it was full again.
> >
> > I was going to complain to my host about it, but then I realized I
> > wasn't sure how those were supposed to be cleared out.
> > I wasn't sure if they were supposed to auto-magically evaporate, or if I
> > should setup a cron job or something. I've never run into this before so
> > I was hoping one of you might be able to shine some light on it.
>
> Not heavily tested (I ran it twice), but attached is a Python script
> that uses lsof to get a list of open files in a directory, then removes
> any files not in that list (permissions permitting).  Run it from cron.
> Requires Python 2.3 or later.  Don't cut yourself.
You could just use fuser, as well.

Like this:

for file in /tmp/*
do 
    if [ -f $file ] && ! fuser -s $file 
    then 
        echo "$file not used by anything -- removing"
 # put remove stuff here
    fi
done
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.