Author Topic: Empty Tmp Folders?  (Read 1356 times)

Offline CheeseQueen452

  • Hero Member
  • *****
  • Posts: 592
Empty Tmp Folders?
« on: September 25, 2010, 09:19:48 AM »
Is it safe to empty both tmp folders? There's a few hundred MB of files that I'd like to get rid of if possible. My hard drive is smaller than what most people have these days, so I like to do a little "house cleaning" now & then....

Offline menotu

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 15307
  • ┌∩┐(◕_◕)┌∩┐
Re: Empty Tmp Folders?
« Reply #1 on: September 25, 2010, 09:34:36 AM »
Have you tried Bleachbit? That's pretty good at cleaning out extraneous gumph
PCLinuxOS 32bit KDE 4.10.1; kernel-3.4.11-pclos1.bfs & 64bit 3.2.18bfs; NVidia GeForce 8400GS 1GB 310.19 driver

Sony Vaio SVE1513A4ESI Laptop, Intel Core i5, 2.6GHz, 6GB RAM, 750GB, 15.6" Intel HD Graphics 4000

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6380
  • I'm going South
Re: Empty Tmp Folders?
« Reply #2 on: September 25, 2010, 10:43:36 AM »
Is it safe to empty both tmp folders? There's a few hundred MB of files that I'd like to get rid of if possible. My hard drive is smaller than what most people have these days, so I like to do a little "house cleaning" now & then....

It usually is, at least if you reboot immediately afterwards. But typically you'll have a lot more than two tmp folders.

~/tmp, /root/tmp and /var/tmp may or may not be symlinks to /tmp, and if they are, they'd be emptied automatically when you empty /tmp. The same goes for temporary directories that are links to subdirectories under /tmp.

But some programs (e.g. e-mail clients) create tmp folders galore. Is it safe to empty them? The program that created them will usually empty them when they aren't needed anymore, so be careful.

If you have lots of RAM, consider moving /tmp to RAM, and it will be empty every time you reboot.
« Last Edit: September 25, 2010, 03:28:13 PM by blackbird »
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Empty Tmp Folders?
« Reply #3 on: September 26, 2010, 01:12:56 AM »
Blackbird,
                    is there a recommended method of emptying /tmp (when used on a HDD not RAM) at each shut-down?
  This, it seems, would have similar effect to using RAM /tmp and be suitable for those with insufficient memory to do so.

Maybe something linked to the "Shutdown" command, rather than "Reboot" or other?

Thanks.

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6380
  • I'm going South
Re: Empty Tmp Folders?
« Reply #4 on: September 26, 2010, 05:41:21 AM »
I don't think there is a recommended way. A couple of years ago I used a script that I found on the net, but it seems that I haven't saved it.

Just adding the lines
Code: [Select]
rm -rf /tmp/*
rm -rf /tmp/.*
to ~/bash_logout will remove everything in /tmp that is owned by your normal user at logout or shutdown, but unfortunately I don't think that it will touch anything owned by root.

I'll try some googling.

Edit. I found this: http://www.linuxquestions.org/questions/linux-general-1/script-to-empty-tmp-folder-415361/.

I suppose one could simply edit /etc/rc.d/init.d/halt to empty /tmp at shutdown, but I'd hesitate editing files in init.d, not because it's dangerous but because I tend to forget what I've done....
« Last Edit: September 26, 2010, 06:02:48 AM by blackbird »
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline parnote

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 4438
  • The truth is out there ... PCLinuxOS!
Re: Empty Tmp Folders?
« Reply #5 on: September 26, 2010, 08:41:44 AM »
I suppose one could simply edit /etc/rc.d/init.d/halt to empty /tmp at shutdown, but I'd hesitate editing files in init.d, not because it's dangerous but because I tend to forget what I've done....


Isn't that what comment lines are for?  ::)

parnote
PCLinuxOS Magazine Chief Editor

Linux Registered User #485009

In a world without walls, who needs Windows?

PCLinuxOS Wiki: Contribute tips/tricks/how-to's!

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6380
  • I'm going South
Re: Empty Tmp Folders?
« Reply #6 on: September 26, 2010, 10:23:46 AM »
I suppose one could simply edit /etc/rc.d/init.d/halt to empty /tmp at shutdown, but I'd hesitate editing files in init.d, not because it's dangerous but because I tend to forget what I've done....


Isn't that what comment lines are for?  ::)

parnote

Comment lines? What kind of a sissy do you take me for?

Actually what is hard to remember isn't what a few added lines in a script does, but which script you added them to, particularly when an update has overwritten some system files including the edited script.
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline parnote

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 4438
  • The truth is out there ... PCLinuxOS!
Re: Empty Tmp Folders?
« Reply #7 on: September 26, 2010, 10:31:24 AM »
I suppose one could simply edit /etc/rc.d/init.d/halt to empty /tmp at shutdown, but I'd hesitate editing files in init.d, not because it's dangerous but because I tend to forget what I've done....


Isn't that what comment lines are for?  ::)

parnote

Comment lines? What kind of a sissy do you take me for?

Actually what is hard to remember isn't what a few added lines in a script does, but which script you added them to, particularly when an update has overwritten some system files including the edited script.


Keep a written log book of what you do, where you do it, and when you did it? You could even keep such a file on your computer, but the drawback is if your computer goes down. I guess you could place it in your Dropbox folder, so that every time you update it, you have an automatic backup.

blackbird, we can go on about this stuff all day. And I'm not saying I do any of this ... I'm just playing the Devil's advocate.  ::)

parnote
PCLinuxOS Magazine Chief Editor

Linux Registered User #485009

In a world without walls, who needs Windows?

PCLinuxOS Wiki: Contribute tips/tricks/how-to's!

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6380
  • I'm going South
Re: Empty Tmp Folders?
« Reply #8 on: September 26, 2010, 10:38:19 AM »
 ;D ;D
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline CheeseQueen452

  • Hero Member
  • *****
  • Posts: 592
Re: Empty Tmp Folders?
« Reply #9 on: September 27, 2010, 04:30:45 PM »
So, what's the best way to do this? I used bleachbit, but it didn't get rid of everything since some of the options gave me a warning that it could cause a problem. I see few suggestions here, but I want to make sure I use the safest/easiest method.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: Empty Tmp Folders?
« Reply #10 on: September 27, 2010, 04:47:56 PM »
So, what's the best way to do this? I used bleachbit, but it didn't get rid of everything since some of the options gave me a warning that it could cause a problem. I see few suggestions here, but I want to make sure I use the safest/easiest method.

Well I am not the one to advise .....  I take 'tmp' rather literally, and believe that any app that uses it to store anything in the long term (between boots) is misbehaving.
So I have no hesitation - for me - in deleting everything under /tmp at each reboot.

I do not agree with deleting anything there between logins .......

We'll see what others have to say about it ....

Offline CJ

  • Sr. Member
  • ****
  • Posts: 454
Re: Empty Tmp Folders?
« Reply #11 on: September 28, 2010, 04:57:05 AM »
If I am not mistaken... yup, in PCC, under Boot -> Set up boot system, then click on Advanced and you have a check mark for Clean /tmp at each boot.

Cheers!
CJ

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6380
  • I'm going South
Re: Empty Tmp Folders?
« Reply #12 on: September 28, 2010, 05:03:50 AM »
If I am not mistaken... yup, in PCC, under Boot -> Set up boot system, then click on Advanced and you have a check mark for Clean /tmp at each boot.

Cheers!
CJ


You have, but ticking that check box adds the line
Code: [Select]
none /tmp tmpfs defaults 0 0to /etc/fstab. In other words, it moves /tmp to RAM, which will indeed guarantee that /tmp is empty when you reboot.

JohnBoy, however, asked about
Quote
emptying /tmp (when used on a HDD not RAM)
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D

Offline CJ

  • Sr. Member
  • ****
  • Posts: 454
Re: Empty Tmp Folders?
« Reply #13 on: September 28, 2010, 05:08:11 AM »
If I am not mistaken... yup, in PCC, under Boot -> Set up boot system, then click on Advanced and you have a check mark for Clean /tmp at each boot.

Cheers!
CJ


You have, but ticking that check box adds the line
Code: [Select]
none /tmp tmpfs defaults 0 0to /etc/fstab. In other words, it moves /tmp to RAM, which will indeed guarantee that /tmp is empty when you reboot.

JohnBoy, however, asked about
Quote
emptying /tmp (when used on a HDD not RAM)


I then postulate that the description of the check box is somewhat misleading. Nevertheless, good (for me) to know, as I have 8gb RAM, and since your clarification, this might be a good option for me.

Cheers!
CJ

Offline Bald Brick

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 6380
  • I'm going South
Re: Empty Tmp Folders?
« Reply #14 on: September 28, 2010, 05:22:49 AM »
I then postulate that the description of the check box is somewhat misleading.

It certainly is. Those with very little RAM should be told what ticking it really does.

Quote
Nevertheless, good (for me) to know, as I have 8gb RAM, and since your clarification, this might be a good option for me.

I also have 8GB and I have had the check box ticked for a year and a half with no negative effects. And RAM is faster than a hard drive.
Feed the trolls!
They need it!

AMD Athlon 7450 Dual-Core Processor, 7.80 GiB RAM, Nvidia GeForce GT 120/PCIe/SSE2, OpenGL/ES-version: 3.3 0 NVIDIA 295.40, SBx00 Azalia (Intel HDA) soundcard, ‎Logitech B500 webcam, SAA7146 DVB card, HDDs: Seagate 250824AS, Western Digital WD10EAVS-00D