LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Is it safe to delete everything from /tmp (http://www.linuxquestions.org/questions/slackware-14/is-it-safe-to-delete-everything-from-tmp-4175459366/)

J1NKL3 04-23-2013 09:33 PM

Is it safe to delete everything from /tmp
 
Have a sizeable amount growing (including a bunch from /tmp/SBo), safe to delete it?

willysr 04-23-2013 09:45 PM

Yes, it's safe to delete them
it will be re-created when you decided to build another package from SBo

ReaperX7 04-24-2013 12:20 AM

You could backup the created packages just to be safe to create your own repository so you dont have to rebuild them in case of a reformat or a package getting overwritten accidentally.

ruario 04-24-2013 12:49 AM

There are three solutions to automatically clear it down here:

http://docs.slackware.com/howtos:gen...ree_your_space

Beelzebud 04-24-2013 01:12 AM

Be careful deleting everything from /tmp. Sometimes there are things in there you don't want to remove, especially on a completely default setup. Here is how I dealt with it, in a safe fashion:

Create /etc/rc.d/rc.local_shutdown

Code:

#! /bin/sh
# 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.;

save the file and run chmod +x on it

This will only delete files that haven't been accessed in 10 days.

pan64 04-24-2013 03:12 AM

yes, there can be some files currently in use...

ottavio 04-24-2013 04:05 AM

Quote:

Originally Posted by pan64 (Post 4937800)
yes, there can be some files currently in use...

If they are in use you won't be able to delete them.

Better to add a line in rc.local.

pan64 04-24-2013 04:11 AM

Quote:

Originally Posted by ottavio (Post 4937839)
If they are in use you won't be able to delete them.

No, it is not true. for example during a compilation (or any other complex processes) there can be work files stored in /tmp. Different phases of that process can read or write those files and you are allowed to delete them - and therefore fool your process.

ChrisAbela 04-24-2013 05:53 AM

The reply to your question is "It depends ..."

In my case, I export OUTPUT to a repository in the /home directory to keep all the packages I build. I noticed that unless there at least one logged-in user, the /tmp directory is not used, so in /etc/rc.d/rc.local I entered the following

cd /tmp
find . -exec rm -rf {} \; 2> /dev/null

wildwizard 04-24-2013 06:17 AM

Quote:

Originally Posted by pan64 (Post 4937850)
No, it is not true. for example during a compilation (or any other complex processes) there can be work files stored in /tmp. Different phases of that process can read or write those files and you are allowed to delete them - and therefore fool your process.

Unless the program closes the file handle the file will never be truly deleted.

pan64 04-24-2013 07:14 AM

Quote:

Originally Posted by wildwizard (Post 4937910)
Unless the program closes the file handle the file will never be truly deleted.

for example gcc is a wrapper and calls a few processes like cpp. Those processes will create files in /tmp (and of course they use the previously generated ones). Yes, you are right the processes will keep the files as long as they exist, but in the next step the removed file will not be available therefore the compiling process will be broken.
The parent process (gcc itself) does not open that file just uses its name and passes it to the child processes.

Habitual 04-24-2013 12:55 PM

Code:

cd /usr/src
wget http://helmut.hullen.de/filebox/Linux/slackware/a/tmpwatch-2.9.16-i386-1hln.tgz
installpkg tmpwatch-2.9.16-i386-1hln.tgz

sudo crontab -e
Code:

*/15 * * * * /usr/sbin/tmpwatch --atime 1 /tmp --exclude=/tmp/SBo/ > /dev/null 2>&1
will delete contents of /tmp every 15m on your system but will exclude the /tmp/SBo directory.

I used to have to (re)create the /tmp/SBo directory every time I run # sbopkg
so I use the above in cron to keep /tmp nice and tidy.

It's never hurt anything on my system when I deleted /tmp/SBo

arubin 04-24-2013 12:58 PM

I have /tmp in RAM so it is deleted every time I turn off my computer.

digger95 04-24-2013 01:14 PM

This has been a very useful thread to me so thanks to everyone.


All times are GMT -5. The time now is 03:02 PM.