SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
/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.
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705
Rep:
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:
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...
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.