LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 03-11-2006, 03:23 PM   #1
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 54
Question /tmp filling up


I did my usual df -h and I saw that my system had grown 1.2 G from its former happy size over the past week. WTF!?

I cruised around until I found 1.2G worth of stuff on /tmp.

I was in a good mood, so I blasted all of it. Luckily, the system still comes up fine.

How are you guys managing /tmp? I have logrotate working fine (FYI for new guys, you have to force it once to set the dates or it won't ever work) and so that part is under control.

Thanks,
Randux
 
Old 03-11-2006, 08:00 PM   #2
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
the /tmp contents on my PC get cleared upon proper reboot/shutdown - i added a couple lines to /etc/rc.d/rc.0 in order for that to happen... of course on a server this wouldn't be the right approach...
 
Old 03-11-2006, 08:18 PM   #3
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Original Poster
Rep: Reputation: 54
It's a desktop dev machine. Which "couple lines" did you add?

Can you just do a rm -r /tmp/* Or did you have another trick?

Thanks,
Rand
 
Old 03-11-2006, 10:00 PM   #4
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
yeah, i just added a couple rm commands (one for hidden files/dirs), like:
Code:
echo "Clearing /tmp ..."
rm -fr /tmp/* 2> /dev/null
rm -fr /tmp/.* 2> /dev/null
i inserted them right before the "Turn off swap, then unmount local file systems" line which is near the end...
 
Old 03-11-2006, 10:03 PM   #5
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
If you use tmpfs for /tmp then it automatically is cleared on reboot. Is there a reason you don't have it setup like that?
 
Old 03-11-2006, 10:10 PM   #6
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally Posted by cs-cam
If you use tmpfs for /tmp then it automatically is cleared on reboot. Is there a reason you don't have it setup like that?
i can't speak for randux, but the reason i don't use shmfs/tmpfs on my box's /tmp is cuz i do a lot of stuff in /tmp and i really don't want that stuff to impact my RAM...
 
Old 03-12-2006, 03:23 AM   #7
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,192

Rep: Reputation: 101Reputation: 101
I do similarly to win32sux for the desktop, on the server I delete all files not accessed for 7 days
 
Old 03-12-2006, 03:52 AM   #8
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally Posted by phil.d.g
I do similarly to win32sux for the desktop, on the server I delete all files not accessed for 7 days
that's pretty cool man...

could you show us what the commands look like?? you run them using cron, right??


EDIT: i was just thinking and i figured perhaps you're doing something like this (i'm not sure):
Code:
find /tmp -atime 7 -exec rm -f {} \;
i believe running something like that about once a day from cron might do the trick??

Last edited by win32sux; 03-12-2006 at 04:18 AM.
 
Old 03-12-2006, 04:31 AM   #9
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,192

Rep: Reputation: 101Reputation: 101
Yeah, though I'm not sure if you had a structure like

/tmp
/tmp/foo
/tmp/foo/bar.txt

and bar.txt was accessed or edited if /tmp and /tmp/foo would be marked as accessed, so I also do a check for if a file is a directory

Code:
find /tmp -regex '^/tmp/.*' -atime +6 | sort -r \
| while read file; do
        if [ -d "$file" ]; then
                rmdir --ignore-fail-on-non-empty "$file"
        else
                rm -f "$file"
        fi
done
The regex means that the dir /tmp will never be deleted, otherwise if it hasn't been accessed for 7 days and it was empty it would be deleted. Of course that would fail if the search path '/tmp' had a trailing slash. Also 6 instead of 7 because find ignores fractional days.

For reference, on the workstation in rc.shutdown (arch) I have
Code:
rm -rf /tmp && mkdir -m0777 /tmp
 
Old 03-12-2006, 04:49 AM   #10
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
hey thanks for that script man!! it's very useful stuff!!

question about your rc.0/rc.shutdown line: why no sticky bit?? just curious...

question #2: my server's filesystems (reiserfs v3) get mounted with the "noatime" option... does that make the find by atime not doable??
Code:
/dev/hda1        /                reiserfs    defaults,noatime 0   0

Last edited by win32sux; 03-12-2006 at 04:53 AM.
 
Old 03-12-2006, 05:08 AM   #11
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,192

Rep: Reputation: 101Reputation: 101
Quote:
Originally Posted by win32sux
question about your rc.0/rc.shutdown line: why no sticky bit?? just curious...
I think that may be a side affect of trying to do an install at 3 in the morning and keep saying to myself: "If I can just get to point X, then I'll be happy and go to bed". I've never picked up on it since. However I've changed it now, thanks for pointing it out.

Quote:
Originally Posted by win32sux
question #2: my server's filesystems (reiserfs v3) get mounted with the "noatime" option... does that make the find by atime not doable??
From what I understand no, two solutions spring to mind though. Either use the last modified property (mtime I think), or better IMHO (which is what I do) have /tmp on a separate partition and don't use noatime for that partition
 
Old 03-12-2006, 05:17 AM   #12
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
cool! thanks!
 
Old 03-12-2006, 11:38 AM   #13
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Original Poster
Rep: Reputation: 54
Thanks guys, I'll look into this. I hadn't changed anything from the vanilla 10.2 install.

Regards,
Randux
 
Old 03-12-2006, 06:38 PM   #14
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534Reputation: 534
Possibly this mini how-to will help:

Removing Temporary Files and Clutter
 
Old 03-12-2006, 07:29 PM   #15
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Original Poster
Rep: Reputation: 54
Thanks, I think the vanilla rm * will work for my setup.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
kde, /tmp, /var/tmp and all that garba Linux - Software 4 06-17-2005 12:31 PM
Create file using 'touch ./tmp.$$', file tmp.3941 is created, why? huangyanfeng Linux - General 1 04-13-2004 03:36 AM
"/tmp/sv001.tmp/setup.bin" error while installing OO1.1.0 Choey Linux - Software 0 09-16-2003 04:52 PM
Numerous scb_*.tmp files in /tmp dburk Programming 3 08-18-2003 04:28 PM
Newbie question - /tmp /var/tmp Mr happy Linux - Security 3 01-27-2003 01:03 PM


All times are GMT -5. The time now is 04:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration