LinuxQuestions.org
Visit Jeremy's Blog.
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 01-14-2007, 05:22 AM   #1
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Rep: Reputation: 55
Question Is it safe to delete the contents of /tmp?


Hello!
I am running Slackware Linux 11.0
I want to ask if it is safe to delete entirely the contents of the /tmp directory, in order to free space? Is there something necessary for the system there?
I would also like to know if there are some other directories where one can safely delete everything from time to time, without any risk.

Thank you for your attention.
Regards,
Martin
 
Old 01-14-2007, 05:46 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

/tmp is needed by programs to store (temporary) information.

It's not a good idea to delete files in /tmp while the system is running, unless you know exactly which files are in use and which are not.

/tmp can (should) be cleaned during a reboot. Some distro's do this by default, others don't.

You could check the log directories and remove old logfiles (maybe set up logrotate to automate rotation and removal of old files).

To check for large files you can do the following (as root):

cd /
du -sh *


This will give you a list with dirs and their size. From here you can zoom in on the biggest dir(s) and repeat the du -sh process.

Hope this helps.
 
Old 01-14-2007, 05:52 AM   #3
The Headacher
Member
 
Registered: Jan 2007
Distribution: Vector Linux
Posts: 90

Rep: Reputation: 15
Well, no permanent harm should be done if you remove /tmp. As a matter of fact, my distro has /tmp in RAM, to speed up things a little. So, every time you boot you'll have a clean /tmp. Make sure you save important work you might be doing before cleaning up /tmp/ though, just to be sure.
 
Old 01-14-2007, 06:49 AM   #4
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Question

Quote:
Originally Posted by druuna
/tmp can (should) be cleaned during a reboot. Some distro's do this by default, others don't.
It seems that Slackware does not clean /tmp on reboot. To which script and where in the script should I add something like:
sudo rm -rf /tmp/*
so that at reboot my system is with a brand new /tmp?
I think it should be added to /etc/rc.d/rc.6, but I am not sure where I should place the above line of code.

Last edited by tramni1980; 01-14-2007 at 06:51 AM.
 
Old 01-14-2007, 07:00 AM   #5
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 55
Quote:
Originally Posted by tramni1980
Hello!
I am running Slackware Linux 11.0
I want to ask if it is safe to delete entirely the contents of the /tmp directory, in order to free space? Is there something necessary for the system there?
I would also like to know if there are some other directories where one can safely delete everything from time to time, without any risk.

Thank you for your attention.
Regards,
Martin
Yes it is safe as long as you are either shutting down or coming up and nobody is using it.

There were a few posts on the topic of what to do about this and many guys said that they write simple shutdown scripts to delete everything in /tmp. Otherwise it will fill with junk over time.

You can write a script to run at shutdown and do this:

rm -rf /tmp/* 2> /dev/null
rm -rf /tmp/.* 2> /dev/null

Rand
 
Old 01-14-2007, 07:01 AM   #6
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 55
I posted before seeing your update. You can add it right before "turning off swap and unmounting..."
 
Old 01-14-2007, 08:11 AM   #7
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Thank you very much for your responsiveness.

Regards,
Martin
 
Old 01-14-2007, 02:05 PM   #8
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
I've found it to not be quite as safe ... unless you do it at shutdown. If you really have to, do it at shutdown.
 
Old 01-14-2007, 02:35 PM   #9
Prostetnic_Jeltz
Member
 
Registered: Feb 2006
Posts: 66

Rep: Reputation: 16
here's a great utility to help you free up space on disk:

http://xdiskusage.sourceforge.net/
 
Old 01-14-2007, 02:48 PM   #10
slzckboy
Member
 
Registered: May 2005
Location: uk - Reading
Distribution: slackware 14.2 kernel 4.19.43
Posts: 462

Rep: Reputation: 30
http://www.linuxquestions.org/questi...d.php?t=505984
 
Old 01-14-2007, 03:28 PM   #11
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
Theres no right or wrong way, but I think its more proper from within rc.S. Why make another section somewhere else when Pat is already doing the same thing in rc.S?

snip of my rc.S
Code:
# Clean up some temporary files:
( cd /var/log/setup/tmp && rm -rf * )
/bin/rm -f /var/run/utmp /var/run/*pid /etc/nologin /var/run/lpd* \
  /var/run/ppp* /etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \
  /var/state/saslauthd/saslauthd.pid /root/.serverauth.* /root/.recently-used
echo "Cleaning /tmp"
mkdir /saved-packages
mv /tmp/*.tgz /saved-packages > /dev/null 2>&1
rm -rf /tmp/*
mv /saved-packages/* /tmp > /dev/null 2>&1
rm -rf /saved-packages

# Create /tmp/{.ICE-unix,.X11-unix} if they are not present:
if [ ! -e /tmp/.ICE-unix ]; then
  mkdir -p /tmp/.ICE-unix
  chmod 1777 /tmp/.ICE-unix
fi
if [ ! -e /tmp/.X11-unix ]; then
  mkdir -p /tmp/.X11-unix
  chmod 1777 /tmp/.X11-unix
fi
I build packages all the time and there is NOTHING MORE FRUSTRATING than rebooting but yet forgetting to snag my packages first...

Last edited by jong357; 01-14-2007 at 03:30 PM.
 
Old 01-14-2007, 08:12 PM   #12
pbhj
Member
 
Registered: Dec 2002
Location: UK
Distribution: Slackware 12; Ubuntu 7.10
Posts: 358

Rep: Reputation: 32
don't delete /tmp without a backup!

I recall, vaguely, doing this - deleting entire content of /tmp - and finding that KDE wouldn't start after next boot. YMMV.

I now have in /etc/rc.d/rc.local_shutdown (which is surely the place for local variations on shutdown scripts ... not rc.S!).

Code:
# Clear /tmp directory of older files (>10 days since accessed)
find /tmp -type f -atime +10 -exec rm {} \;
echo rc.6: deleting /tmp files not accessed in 10 days;
 
Old 01-14-2007, 10:38 PM   #13
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
Well, who says /tmp should be cleared on shutdown? Most distro's I'm aware of do it on startup. Since Slackware allready cleans tmp cruft up in rc.S, that would make it a prime canidate for such modifications.

I do like removal by time tho. In some cases that wouldn't help me because I can accumulate gigabytes worth of stuff in just a few hours. It all depends on how much hard drive space you have I suppose.

Last edited by jong357; 01-14-2007 at 10:40 PM.
 
Old 01-15-2007, 07:52 AM   #14
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
I find either way to work and think it's a matter of choice. Pat probably doesn't do it by default because it might delete something you want or need. Doing it in rc.S where the other stale files are cleaned up makes perfect sense to me -though it may add considerable time to the bootup. Doing it in rc.local_shutdown is probably better from a data-security standpoint.
I don't doubt that there are programs which may complain, but with the desktop I run I can usually delete the whole contents, even on-the-fly, without any problems.
 
Old 01-15-2007, 09:23 AM   #15
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Rep: Reputation: Disabled
I have been using rc.6 to:
Quote:
rm -rf /tmp/* /var/tmp/*
I have been warned by various posts that deleting /var/tmp is dangerous, but I have never had any problems.

jong357:
I've had hassles with my scripts as well, so I defined an variable, OUTPUT, per shilo's recent slackbuild post, & set a safe destination for them.
Regards,
Bill
 
  


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
Is it OK to delete everything in /tmp? forrest44 Slackware 12 11-15-2005 10:47 PM
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
file:/tmp - mysterious contents. Rm, or not rm? linuxfond Linux - Newbie 5 06-12-2004 02:00 PM
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 03:20 PM.

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