LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-14-2006, 11:51 AM   #1
capnp72
LQ Newbie
 
Registered: Jan 2006
Location: Hampton, VA
Distribution: fedora core 4
Posts: 22

Rep: Reputation: 15
script to empty /tmp folder


I'm using SUSE 10 with gnome desktop. I would like to write a sript to empty the /tmp folder when I log out. How do I write the script?
 
Old 02-14-2006, 02:23 PM   #2
Dudydoo
Member
 
Registered: Sep 2003
Location: UK
Distribution: I use 'em all ;-)
Posts: 275

Rep: Reputation: 38
Add this to your ~/bash_logout file.

Code:
rm -rf /tmp/* 2>& /dev/null

Last edited by Dudydoo; 02-14-2006 at 02:25 PM.
 
Old 02-14-2006, 04:52 PM   #3
capnp72
LQ Newbie
 
Registered: Jan 2006
Location: Hampton, VA
Distribution: fedora core 4
Posts: 22

Original Poster
Rep: Reputation: 15
I did what you said. I put that line into the file you specified but it's deleting all the files in the /tmp folder.
 
Old 02-14-2006, 05:42 PM   #4
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
When you reboot your machine, the /tmp directory is wipped out (If that helps at all).
 
Old 02-14-2006, 05:50 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by capnp72
I did what you said. I put that line into the file you specified but it's deleting all the files in the /tmp folder.
That's exactly what you asked for?! How come you're
surprised?


Cheers,
Tink
 
Old 02-15-2006, 07:40 AM   #6
capnp72
LQ Newbie
 
Registered: Jan 2006
Location: Hampton, VA
Distribution: fedora core 4
Posts: 22

Original Poster
Rep: Reputation: 15
I left a word out of my sentence. What I meant to say is: The script is not deleting the files that need root to access.
 
Old 02-15-2006, 08:34 AM   #7
ckoniecny
Member
 
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
You can look into using "sudo". Add this entry to your /etc/sudoers file:

Code:
username     ALL=(ALL) NOPASSWORD: ALL
Then you can run the command
Code:
sudo rm -rf /tmp/* 2>& /dev/null
which will you give you root privileges for that command.
 
Old 02-15-2006, 11:28 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by ckoniecny
You can look into using "sudo". Add this entry to your /etc/sudoers file:

Code:
username     ALL=(ALL) NOPASSWORD: ALL
That's about as "safe" as logging in as root...
Code:
Cmnd_Alias POWEROFF = /sbin/poweroff
Cmnd_Alias REBOOT = /sbin/reboot
Cmnd_Alias CHKIN = /usr/local/sbin/checkinstall
Cmnd_Alias VPN = /sbin/vpn

tink  diggn = NOPASSWD: VPN, CHKIN, POWEROFF, REBOOT, HALT, /sbin/removepkg, /sbin/installpkg, /usr/sbin/adduser,  /sbin/ifconfig, rm -rf /tmp/*

Much more sane...


Cheers,
Tink
 
Old 02-15-2006, 12:50 PM   #9
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Why do you want to delete files from /tmp that don't belong to you? You could negatively affect other users or applications by doing this. The reason you cannot delete files that you don't own from /tmp, despite /tmp's permissions of 777, is because the sticky bit is set on the directory. root can obviously delete them, hence the suggestions for using sudo, but I'm not sure it's adviseable to trigger this cleanup when a single (normal) user logs off.
 
  


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 On
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 01:43 PM
/var/tmp folder hardeep_ubhi Linux - General 4 10-02-2006 07:10 AM
Is it necessary to empty /tmp while booting? rsamurti Slackware - Installation 1 07-11-2004 10:21 AM
How do I empty the /tmp folder at boot? Posty Slackware 13 10-12-2003 08:36 PM
tmp folder question synaptical Linux - General 8 08-31-2003 03:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:50 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