LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 11-14-2005, 04:10 AM   #1
forrest44
Member
 
Registered: May 2004
Location: In the staple gun
Distribution: slackware4life
Posts: 119

Rep: Reputation: 15
Is it OK to delete everything in /tmp?


well I've got slackware 10.0 on my computer..

I'm pretty tight for disk space, and I noticed that the /tmp directory had about 120mb of stuff in it.

Is it ok to delete EVERYTHING in the /tmp directory or is there some stuff I need to leave behind?

Cheers
Forrest
 
Old 11-14-2005, 04:19 AM   #2
LiNuCe
Member
 
Registered: Apr 2004
Location: France
Distribution: Slackware Linux 10.2
Posts: 119

Rep: Reputation: 15
Re: Is it OK to delete everything in /tmp?

Yes, you can remove everything in /tmp. A (the?) proper way to do this is to login as root, then to switch to single user mode with the init 1 command and to use the following commands to create a sane /tmp hierarchy :

Code:
# rm -rf /tmp
# mkdir -m 1777 /tmp
# mkdir -m 1777 /tmp/.ICE-unix
# mkdir -m 1777 /tmp/.X11-unix
You can then reboot if you wish or you can switch back to multi-user mode with the init 4 command.

--
LiNuCe
 
Old 11-14-2005, 04:29 AM   #3
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Personally, I avoid the issue altogether and run a 'tmpfs', i.e: a ramdisk which is mounted under /tmp at bootup. Don't have to worry about deleting stuff this way - it goes away when I shutdown the computer.

Refer to /path/to/kernel/source/Documentation/filesystems/tmpfs.txt for more info.
 
Old 11-14-2005, 05:02 AM   #4
LiNuCe
Member
 
Registered: Apr 2004
Location: France
Distribution: Slackware Linux 10.2
Posts: 119

Rep: Reputation: 15
Quote:
rkelsen: Refer to /path/to/kernel/source/Documentation/filesystems/tmpfs.txt for more info.
Another interesting reading before switching to tmpfs is this article published by IBM.

--
LiNuCe
 
Old 11-14-2005, 05:37 AM   #5
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,448
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Quote:
Originally posted by LiNuCe
Another interesting reading before switching to tmpfs is this article published by IBM
The change to 'tmpfs' will only be permanent if you want it to be. Try it. If it degrades your system performance, switch back. Simple.

In ~ 4 years (or however long its been since tmpfs came out) I've not experienced the problems discussed in the IBM article. But then I like to load my mobos with all the RAM they can carry.
 
1 members found this post helpful.
Old 11-14-2005, 08:32 AM   #6
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
That's not a bad idea with tmpfs... I just append to the startup script. When it cleans /var/lock, I have it wipe /tmp as well. Those required sockets seem to get created automatically.
 
Old 11-14-2005, 01:53 PM   #7
forrest44
Member
 
Registered: May 2004
Location: In the staple gun
Distribution: slackware4life
Posts: 119

Original Poster
Rep: Reputation: 15
Well thanks for all the help..

I'm guessing it would be OK to add something like "rm -rf /tmp" to the shutdown script?
 
Old 11-14-2005, 01:54 PM   #8
forrest44
Member
 
Registered: May 2004
Location: In the staple gun
Distribution: slackware4life
Posts: 119

Original Poster
Rep: Reputation: 15
Oh and I don't think I'll use the tmpfs thing, I've only got 128mb ram
 
Old 11-14-2005, 05:16 PM   #9
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.1
Posts: 3,482

Rep: Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546Reputation: 546
I run KDE. In my rc.local, I run two scripts:

#!/bin/bash
# /usr/local/sbin/deleteoldfiles
# delete old tmp files

echo "Deleting old tmp files."
TMPDIRS="/tmp /var/tmp" # list of directories to clean
for d in $TMPDIRS; do
find $d ! -type d -mtime +10 -exec rm -f {} \;
find $d -type d -mtime +10 -exec rmdir {} \;
done

#!/bin/bash
# /usr/local/sbin/cleanup
# delete various tmp files

echo "Deleting various tmp files."
# first delete known single files
rm -f /tmp/.ICE-unix/* /tmp/kio*
# next delete files recursively
rm -rf /tmp/kde-root/* /tmp/kde-username/* /tmp/kde-tester/* /tmp/.wine*

# Delete login manager logs for easier session troubleshooting and maintenance
rm -f /var/log/kdm.log >/dev/null
rm -f /var/log/xdm.log >/dev/null
# rm -f /var/log/gdm.log >/dev/null


The ideas for the scripts are not original. I saw what some other people have done and simply adopted the ideas. I hope this helps.
 
Old 11-14-2005, 05:54 PM   #10
LiNuCe
Member
 
Registered: Apr 2004
Location: France
Distribution: Slackware Linux 10.2
Posts: 119

Rep: Reputation: 15
Quote:
forrest44: I'm guessing it would be OK to add something like "rm -rf /tmp" to the shutdown script?
I think it should be safe to replace the following line :
Code:
echo "Unmounting local file systems."
with the following ones in the /etc/rc.d/rc.6 shutdown script :
Code:
rm -rf /tmp
mkdir -m 1777 /tmp
echo "Unmounting local file systems."
--
LiNuCe
 
Old 11-15-2005, 03:15 PM   #11
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 48
Or you could have a cron script for cleaning up /tmp, something like:

Code:
#!/bin/bash
find /tmp -type f -atime +3 -exec rm {} \;
The above would find all regular files not accessed in three days and remove them. It's better than shutdown/startup script solution since it will also work if you keep your box powered up.

Last edited by alienDog; 11-15-2005 at 03:16 PM.
 
1 members found this post helpful.
Old 11-15-2005, 08:50 PM   #12
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
I like that even better... I've gotten in the habit of never using /tmp to store stuff, but you never know. You could build a new mozilla package and then forget to remove it before a reboot. Then you'd have to spend another hour building the package...

Nice suggestion aliendog.
 
Old 11-15-2005, 10:47 PM   #13
LiNuCe
Member
 
Registered: Apr 2004
Location: France
Distribution: Slackware Linux 10.2
Posts: 119

Rep: Reputation: 15
Quote:
jong357: I like that even better... I've gotten in the habit of never using /tmp to store stuff, but you never know. You could build a new mozilla package and then forget to remove it before a reboot. Then you'd have to spend another hour building the package...
The traditional pratice is to assume that temporary files in /tmp/ are removed between system reboots, whereas temporary files in /var/tmp/ are not . So, if you want to keep temporary files between reboots, you would probably store them in /var/tmp/. By default, Slackware Linux does not remove temporary files in /tmp/ between reboots, however many Unix/Linux systems remove them (or store them in a temporary filesystem such as tmpfs). Note that you can ignore this traditional pratice on your system until Slackware Linux uses tmpfs for /tmp/ by default, but this is something to know to avoid problems on others systems.

--
LiNuCe
 
  


Reply



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
2 gigabyte /tmp directory..ok to delete contents pAn1k Linux - Newbie 3 09-02-2004 09:56 AM
How do I delete /tmp partition? akihandyman Mandriva 4 08-08-2004 02:38 PM
Can I delete everything in the /tmp directory? BajaNick Linux - General 5 07-04-2004 01:35 PM
can i delete /tmp files? demmylls Linux - General 1 03-01-2004 10:14 AM
Delete all in /tmp ??? shreev Slackware 5 08-07-2003 04:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:51 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration