LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-25-2013, 08:16 PM   #1
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,198

Rep: Reputation: 47
Command to clean tmp at shutdown


According to http://docs.slackware.com/howtos:gen...ree_your_space, following command should be put in /etc/rc.d/rc.local_shutdown :
Code:
/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -print0 | xargs -0r /bin/rm -rf
Why not put a simple command:
Code:
rm -rf /tmp/*
 
Old 07-25-2013, 08:40 PM   #2
cisneros
Member
 
Registered: Jul 2012
Distribution: Slackware
Posts: 95

Rep: Reputation: 5
so if the script fails the deleting process does not stop, because every file triggers a different rm process, i guess...
 
Old 07-25-2013, 09:01 PM   #3
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,440
Blog Entries: 7

Rep: Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551
tmpfs is a better solution...
 
1 members found this post helpful.
Old 07-25-2013, 09:09 PM   #4
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
Because * does not expand hidden files by default (but can be changed).
BTW, tmpfs is much slower than ext3/4, etc. when it makes extensive use of swap.
 
Old 07-25-2013, 09:20 PM   #5
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 926

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
Quote:
Originally Posted by guanx View Post
Because * does not expand hidden files by default (but can be changed).
BTW, tmpfs is much slower than ext3/4, etc. when it makes extensive use of swap.
That's right, I use "ls -A" to list hidden files and a loop to clean /tmp




Quote:
Originally Posted by cisneros
so if the script fails the deleting process does not stop, because every file triggers a different rm process, i guess...
I didn't know that. But I didn't note any delay at shutdown by cleaning /tmp
 
Old 07-25-2013, 10:13 PM   #6
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,440
Blog Entries: 7

Rep: Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551
Quote:
Originally Posted by guanx View Post
BTW, tmpfs is much slower than ext3/4, etc. when it makes extensive use of swap.
Yes, that makes sense... But surely, modern desktop machines with 6 to 8 gigs of memory wouldn't really need to use swap that much, would they?

In the ~15 years I've been using Linux as my main desktop OS, I almost cannot recall ever seeing it actually use swap... maybe back when my machine had 256Mb RAM and I was running StarOffice on KDE, but certainly not much at all in recent years.
 
Old 07-26-2013, 12:32 AM   #7
Martinus2u
Member
 
Registered: Apr 2010
Distribution: Slackware
Posts: 497

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by rkelsen View Post
Yes, that makes sense... But surely, modern desktop machines with 6 to 8 gigs of memory wouldn't really need to use swap that much, would they?

In the ~15 years I've been using Linux as my main desktop OS, I almost cannot recall ever seeing it actually use swap... maybe back when my machine had 256Mb RAM and I was running StarOffice on KDE, but certainly not much at all in recent years.
totally correct. it doesn't make sense to set up a swap device at all on most machines these days. Unfortunately the internet is still full of braindonated guides advising you to set up swap, sometimes even at twice the size of RAM. But technically guanx is right: it is madness to trade tmpfs for swap. Anything that might trigger the use of swap and thus thrashing should be avoided.
 
Old 07-26-2013, 02:36 AM   #8
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
Quote:
Originally Posted by Paulo2 View Post
That's right, I use "ls -A" to list hidden files and a loop to clean /tmp
As a general best practice, avoid parsing the output of ls if you can. Files containing weird characters can be a problem. The find solution provided in the OP post is a bit more verbose, but totally secure in that regard, using null characters as terminators (a null character can never appear in the middle of a name in Linux).
 
Old 07-26-2013, 03:08 AM   #9
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
I think find/xargs does not introduce more security than the dotglob shopt but find/xargs is more portable and also works when there are too many files.
 
Old 07-26-2013, 03:18 AM   #10
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,176

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by rkelsen View Post
Yes, that makes sense... But surely, modern desktop machines with 6 to 8 gigs of memory wouldn't really need to use swap that much, would they?

In the ~15 years I've been using Linux as my main desktop OS, I almost cannot recall ever seeing it actually use swap... maybe back when my machine had 256Mb RAM and I was running StarOffice on KDE, but certainly not much at all in recent years.
Thanks for sharing your experience. So you rarely used swap since 1998? I believe you because Bill Gates used to say 640kB was enough, and in 1998 you could get 64MB for a PC, nearly 100 times more than enough.

However, 8 GB is not large enough for my temp files. I also use suspend to disk more than once per day. I think I'm far from getting rid of swap.
 
Old 07-26-2013, 03:31 AM   #11
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
Many years ago the ratio between memory speed and disk speed (latency + transfer rate) was low, and memory was VERY expensive - thus virtual memory (page swapped to disk) was plausible. However, since then, memory has become both fantastically cheap and fast, while disk speed has not even come close to matching those advances. 30 years back I was dealing with mainframe disks of 200 MegaBytes in size (quite large then) which had latencies of about 15 millisecs. Now disks are down to maybe 5 millisecs. Transfer rates are better, but maybe 30 to 100 times. Memory is millions of times larger and almost billions of times cheaper. So,, if your system starts swapping in any fashion, it will appear that your machine is driving through treacle. While it's true that SSD's are rewriting those rules, the issues they still have with write-cycles is a problem. Conclusion - don't use memory for temp files : they will increase the likelihood that you will use swap and die.
 
1 members found this post helpful.
Old 07-26-2013, 07:12 AM   #12
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Quote:
Originally Posted by rng View Post
Code:
/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -print0 | xargs -0r /bin/rm -rf
Why not:

Code:
/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -exec /bin/rm -rf {} \;
It seems like the use of xargs is undeeded.
 
Old 07-26-2013, 07:26 AM   #13
fl0
Member
 
Registered: May 2010
Location: Germany
Distribution: Slackware
Posts: 105

Rep: Reputation: 34
Quote:
Originally Posted by ruario View Post
Why not:

Code:
/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -exec /bin/rm -rf {} \;
It seems like the use of xargs is undeeded.
or the same as xargs, but builtin
Code:
/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -exec /bin/rm -rf {} +;
regards fl0
 
1 members found this post helpful.
Old 07-26-2013, 08:56 AM   #14
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,440
Blog Entries: 7

Rep: Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551Reputation: 2551
Quote:
Originally Posted by guanx View Post
However, 8 GB is not large enough for my temp files.
!

what are you possibly doing with your machine to make this true?

to everyone who is saying that tmpfs will cause your machine to swap: you can easily limit the size of a tmpfs. mine is limited to 1 gig, and I've never come anywhere near filling it. this is on a machine with 4gigs ram, and I haven't yet seen any swapping... or at least I haven't noticed it.
 
Old 07-26-2013, 10:02 AM   #15
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,858

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
Originally Posted by rkelsen View Post
!

what are you possibly doing with your machine to make this true?
Well, perhaps he's encoding DVD images in a way that uses a couple of intermediate images.
 
  


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
[SOLVED] Clearing /tmp at shutdown 2handband Slackware 8 11-09-2010 04:14 PM
Automatic clean shutdown on overheating wpost Linux - Hardware 7 05-28-2010 08:56 AM
clean-tmp - cron task suse 10.3 flebber SUSE / openSUSE 2 10-07-2007 01:02 AM
How to clean /tmp mkhan919 Linux - Newbie 7 03-05-2007 01:34 PM
automatically emptying /tmp at shutdown adityavpratap Slackware 13 01-31-2007 09:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:06 AM.

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