LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 10-11-2003, 11:10 PM   #1
Posty
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 62

Rep: Reputation: 15
Question How do I empty the /tmp folder at boot?


Hello Slackware users.

How do I make Slackware empty the /tmp folder automatically each time I boot up?
 
Old 10-12-2003, 12:02 AM   #2
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
Make a script,

'vim /deltmp.sh' 'pico /deltmp.sh'

In this file put:

Code:
#!/bin/bash
rm /tmp/*
Add executable permission's to the file:

'chmod +x /deltmp.sh'

open '/etc/rc.d/rc.M'

add this line to the bottom:

Code:
if [ -x /deltmp.sh ]; then
  /deltmp.sh
else
  echo "'/deltmp.sh' does not exist." 
fi
But of course, there's alway's many way to do something.

Tarts

Last edited by Tarts; 10-12-2003 at 12:06 AM.
 
Old 10-12-2003, 12:19 AM   #3
bender647
LQ Newbie
 
Registered: May 2003
Location: Boston
Distribution: Slackware 10 on i486/586/PentiumM; Solaris 2.8 on sparc; FreeBSD on i686
Posts: 24

Rep: Reputation: 15
Another way

If you look in /etc/rc.d/rc.S, there's a section
there commented "Clean up some temporary
files". You could just add /tmp to the end of
the list there.
___
Ken


[edit] /tmp/* of course

Last edited by bender647; 10-12-2003 at 12:20 AM.
 
Old 10-12-2003, 04:04 PM   #4
Posty
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 62

Original Poster
Rep: Reputation: 15
Adding /tmp/* to it didn't work. The other way doesn't seem neccisary. I have had distros that empty it by default each boot.

Are there other things I may need to add? Like maybe cd /, blah blah something /tmp/*-/tmp?

As you can see I am confused, I am new to Linux (About three weeks new) and I would need this to be explained very plainly and clearly. Please help me out.
 
Old 10-12-2003, 04:16 PM   #5
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 47
I think you could add

rm -Rf /tmp
mkdir /tmp

at the very end of that file (/etc/rc.d/rc.S) or next to the section on cleaning up some temp files. This removes the tmp folder with all its contents and then creates an empty one.
 
Old 10-12-2003, 04:19 PM   #6
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 47
or just rm -Rf /tmp/*

edit: you could also put it in your shutdown scripts so it wouldn't slow down boot time. also IIRC it's a bit dangerous to delete tmp files after going into multiuser mode, so deleting at shutdown helps avoid that.

Last edited by synaptical; 10-12-2003 at 04:23 PM.
 
Old 10-12-2003, 04:23 PM   #7
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 47
Maybe I'm too stupid to figure this out but when I do
rm -Rf /tmp/*
it does not delete the hidden files... So I generally just remove the tmp folder and then recreate it (I do it manually from time to time; not at boot time)
 
Old 10-12-2003, 04:23 PM   #8
Posty
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 62

Original Poster
Rep: Reputation: 15
Cool, I added that now. The thing is some of the text in there was black and some was white. I am useing Kwrite for this all. Anyways, I will reboot now and see if it works. Thanks for the quick reply.
 
Old 10-12-2003, 04:29 PM   #9
synaptical
Senior Member
 
Registered: Jun 2003
Distribution: Mint 13/15, CentOS 6.4
Posts: 2,020

Rep: Reputation: 47
oh, you're right! the hidden files stay. sorry for removing everything, your method is best.
 
Old 10-12-2003, 05:01 PM   #10
Posty
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 62

Original Poster
Rep: Reputation: 15
Right, I will just remove the folder and recreate it then.

Also, and this is unrelated to the /tmp file, when I boot up a always get some "failed" stuff... Let me do dmesg...

i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected
i810_rng: RNG not detected

But when I am booting up it doesn't show it like that. But I know that those are what's causeing the problems. I always catch the "i810".. Any ideas on how to make these go away? So far I have not seen any problems with the functionality of my machine but seeing the errors and failed stuff makes me think there might be somehting wrong. Since these things are not starting and obviously are not needed because my PC is working just fine, can I stop these things?
 
Old 10-12-2003, 09:01 PM   #11
taivu
LQ Newbie
 
Registered: Oct 2002
Location: Spain
Distribution: Ubuntu, Debian Sarge, FreeBSD
Posts: 19

Rep: Reputation: 0
Quote:
Originally posted by quatsch
Maybe I'm too stupid to figure this out but when I do
rm -Rf /tmp/*
it does not delete the hidden files... So I generally just remove the tmp folder and then recreate it (I do it manually from time to time; not at boot time)
rm -fR /tmp/* /tmp/.*
 
Old 10-12-2003, 09:17 PM   #12
quatsch
LQ Addict
 
Registered: Aug 2003
Location: New York, NY
Distribution: gentoo, gentooPPC
Posts: 1,661

Rep: Reputation: 47
Quote:
rm -fR /tmp/* /tmp/.*
right. except that
rm -Rf /tmp.*
complains that it cannot remove . or ..
which is of course a good thing but it still gives me the shivers. Imagine it succeeded in doing that - the whole file system up and down the whole structure deleted in one go.
 
Old 10-12-2003, 09:26 PM   #13
bender647
LQ Newbie
 
Registered: May 2003
Location: Boston
Distribution: Slackware 10 on i486/586/PentiumM; Solaris 2.8 on sparc; FreeBSD on i686
Posts: 24

Rep: Reputation: 15
Hidden files would match /tmp/.* (rm -Rf /tmp/* /tmp/.*)

If you do choose to delete and remake /tmp, make sure
you reset the mode (permissions) properly. I believe its
chmod 1777 /tmp (drwxrwxrwt). You want the sticky bit
set so that even though anyone can write to /tmp, only the
owner of a file may remove the file. If you don't run
multi-user, you probably don't care, but its good practice
and probably good security.
___
Ken
 
Old 10-12-2003, 09:36 PM   #14
smokybobo
LQ Newbie
 
Registered: Feb 2003
Posts: 29

Rep: Reputation: 15
If you want totally safe way with the bash shell you can use:

Code:
rm -rf /tmp/* /tmp/.[!.]*
or if you like regexp style:

Code:
rm -rf /tmp/* /tmp/.[^.]*
Of course, if there's a file with a name like '..four', then it doesn't really work, but then what really names a file/directory with two leading periods?

Last edited by smokybobo; 10-12-2003 at 09:41 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
TMP folder, is everything deletable in there? ginda Linux - Newbie 6 12-16-2006 02:43 PM
/var/tmp folder hardeep_ubhi Linux - General 4 10-02-2006 08:10 AM
Is it necessary to empty /tmp while booting? rsamurti Slackware - Installation 1 07-11-2004 11:21 AM
What is all this junk in the /tmp folder? HoosTrax Linux - Newbie 2 02-10-2004 05:03 PM
tmp folder question synaptical Linux - General 8 08-31-2003 04:10 PM


All times are GMT -5. The time now is 01:19 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration