LinuxQuestions.org
Register a domain and help support LQ
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-26-2013, 10:14 AM   #16
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware current(32) (started with 13.37(32))
Posts: 144

Rep: Reputation: 29

Quote:
Originally Posted by rg3 View Post
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).
Thanks for the advice. I usually always protect vars with double quotes, this doesn't help avoiding problems?




Quote:
Originally Posted by Richard Cranium View Post
Well, perhaps he's encoding DVD images in a way that uses a couple of intermediate images.
Or bluray images
 
Old 07-26-2013, 10:43 AM   #17
irgunII
Member
 
Registered: Jan 2012
Location: Directly above the center of the earth
Distribution: Slackware. There's something else?
Posts: 381

Rep: Reputation: 66
Cleanup of /tmp sounds like a good idea, but when someone says to be careful *what* is cleaned from it, how do we know what to clean?

For instance...my /tmp has a SBo directory which has 13GB of directories/files. This is a *LOT* of space being used up. Is it safe to delete the SBo dir?
 
Old 07-26-2013, 10:57 AM   #18
cisneros
Member
 
Registered: Jul 2012
Distribution: Slackware
Posts: 95

Rep: Reputation: 5
Quote:
Originally Posted by irgunII View Post
Cleanup of /tmp sounds like a good idea, but when someone says to be careful *what* is cleaned from it, how do we know what to clean?

For instance...my /tmp has a SBo directory which has 13GB of directories/files. This is a *LOT* of space being used up. Is it safe to delete the SBo dir?
i think thats the stuff that is made when you use slackbuilds to compile apps, temps files, etc... if you have your pkgs in a safe place it should be ok to delete... not really sure.
 
Old 07-26-2013, 11:01 AM   #19
vdemuth
Member
 
Registered: Oct 2003
Location: West Midlands, UK
Distribution: Slackware 14 (Server),Suse 13.1 (Desktop),, Mepis on the wifes lappy
Posts: 768

Rep: Reputation: 92
I use the following in rc.6


# clean tmp of old and stale files
echo "Cleaning temporary files"
find /tmp -type f -mtime +5 -exec rm -f {} \;
find /var/tmp -type f -mtime +30 -exec rm -f {} \;


Can't remember where it came from but works well and keeps /tmp relatively small
 
Old 07-26-2013, 11:24 AM   #20
Martinus2u
Member
 
Registered: Apr 2010
Distribution: Slackware
Posts: 345

Rep: Reputation: 56
Quote:
Originally Posted by Paulo2 View Post
Or bluray images
Sure, but why would he not create the images on a disk based file system? Sequential file access will always outperform demand paging which does random I/O and sends your system into thrashing.
 
Old 07-26-2013, 11:35 AM   #21
GazL
Senior Member
 
Registered: May 2008
Posts: 3,440

Rep: Reputation: 959Reputation: 959Reputation: 959Reputation: 959Reputation: 959Reputation: 959Reputation: 959Reputation: 959
/tmp is meant to be used as transient workspace for running tasks. Anything that leaves stuff in /tmp when it ends is 'broken'. /var/tmp is intended to be used for more persistent though still non-permanent data. Unfortunately, very few people seem to be aware of this distinction, let alone disciplined enough to actually comply with this concept and use /var/tmp.

Of course, this doesn't mean that something can't put a huge amount of data in /tmp while still using it correctly (Richard's example of an intermediate .iso image being one example - though anything that is going to use a large amount of disk space like that really should be assigned it's own dedicated space so as not to impact the rest of the system and/or its users), but it's more common that a large amount of data collecting in /tmp is just a sign of abuse of the filesystem.

If the programs using /tmp have been correctly written, then in theory you should be able to remove the files in /tmp at any time - even while the programs are still running and it shouldn't cause a problem (because the program will still have an open file-descriptor for it). However, back in the real world, not everyone understands how /tmp is supposed to be used, and even those that do are often just too idle to make the effort to do it properly, so you roll the dice and take your chances.
 
3 members found this post helpful.
Old 07-26-2013, 12:03 PM   #22
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,014

Rep: Reputation: 146Reputation: 146
Quote:
Originally Posted by rkelsen View Post
...
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.
...
That something haven't happened to you doesn't mean it cannot happen to you in the future, or happen to other people.

Yes of course, I know tmpfs can be limited of 1GB, but please understand my frustration when I started compiling the very small code base of qemu, went to bed, and only find the next morning that qemu.SlackBuild terminated because /tmp is full. For compiling another of my daily software, 8GB temporary space is not much more than enough. So if you let me limit /tmp to 1GB then I will have to create a /tmp2 elsewhere anyway. Wired.

Actually I am using a 20GB tmpfs on /tmp, together with a 25GB swap partition. My /tmp consumption is almost always less than 1GB, but when it goes up to 10GB my programs will not break. They just slow down.

I can expect the bad thing to not happen, but I cannot be unprepared. I work with a computer, while you play with a computer. Therefore, we have different points of view.

Last edited by guanx; 07-26-2013 at 08:35 PM.
 
Old 07-26-2013, 07:56 PM   #23
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,771

Rep: Reputation: 205Reputation: 205Reputation: 205
Quote:
Originally Posted by guanx View Post
Yes of course, I know tmpfs have a size limit of 1GB, but please understand my frustration when I started compiling the very small code base of qemu, went to bed, and only find the next morning that qemu.SlackBuild terminated because /tmp is full.
Why not edit the SlackBuild to use your /home/user (or /root) directory instead? SlackBuilds don't have to use /tmp.
Quote:
Originally Posted by guanx View Post
For compiling another of my daily software, 8GB temporary space is not much more than enough.
Again, why aren't you compiling stuff in your /home directory?
Quote:
Originally Posted by guanx View Post
Actually I am using a 20GB tmpfs on /tmp
That's just silly.
Quote:
Originally Posted by irgunII
Is it safe to delete the SBo dir?
Absolutely. In fact, I would recommend it. Files generated by sbopkg take a ton of space in /tmp. And none of them are used after it installs the packages it built.
 
Old 07-26-2013, 08:27 PM   #24
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,014

Rep: Reputation: 146Reputation: 146
Quote:
Originally Posted by rkelsen View Post
Why not edit the SlackBuild to use your /home/user (or /root) directory instead? SlackBuilds don't have to use /tmp.
Edit the SlackBuild? That's just silly. Why not export a different TMP environment variable for use by the SlackBuild?

I actually build software on tmpfs to minimize iowait time because in most (but not all!) cases the intermediate files are smaller than my main memory. (vm.swappiness also plays a role in it but that's another story.)

Quote:
Originally Posted by rkelsen View Post
Again, why aren't you compiling stuff in your /home directory?

That's just silly.
Do you mean $HOME and not /home? I guess you never looked into those SlackBuild scripts, or you wouldn't have suggested me to run them as normal user. On the other hand, if you meant to run SlackBuild as root but put the intermediate files under a normal user's $HOME, that not just silly, that's crazy.

Last edited by guanx; 07-26-2013 at 08:45 PM.
 
Old 07-26-2013, 09:06 PM   #25
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 1,771

Rep: Reputation: 205Reputation: 205Reputation: 205
Quote:
Originally Posted by guanx View Post
Edit the SlackBuild? That's just silly. Why not export a different TMP environment variable for use by the SlackBuild?
Yes. Why don't you do that?
Quote:
Originally Posted by guanx View Post
I actually build software on tmpfs to minimize iowait time because in most (but not all!) cases the intermediate files are smaller than my main memory.
Hmmm.
Quote:
Originally Posted by guanx View Post
Do you mean $HOME and not /home? I guess you never looked into those SlackBuild scripts, or you wouldn't have suggested me to run them as normal user. On the other hand, if you meant to run SlackBuild as root but put the intermediate files under a normal user's $HOME, that not just silly, that's crazy.
Well I did also say /root... But you seem to have ignored that for some reason.

Regardless, I often edit out the 'root only' commands in a SlackBuild to get what I want as a regular user. And you don't have to use SlackBuild scripts for everything, you know...

Last edited by rkelsen; 07-26-2013 at 09:07 PM.
 
Old 07-26-2013, 11:35 PM   #26
Z038
Member
 
Registered: Jan 2006
Distribution: Slackware
Posts: 804

Rep: Reputation: 157Reputation: 157
^ I'm afraid to ask.
 
Old 07-27-2013, 03:32 AM   #27
rg3
Member
 
Registered: Jul 2007
Distribution: Slackware Linux
Posts: 512

Rep: Reputation: Disabled
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.
The point of xargs is (and has always been IIRC) to launch less processes. So if you have 5000 files and directories in /tmp, that commands launches 5000 rm processes, while with xargs maybe you can pass 256 arguments at a time, for example, or even more.

That said, this reminds me of a recent benchmark I read about in Hacker News which tried to find the fastest way to delete a million files, and find with xargs was actually slower in some cases than find with -delete.

http://linuxnote.net/jianingy/en/lin...-of-files.html
 
Old 07-27-2013, 03:48 AM   #28
rg3
Member
 
Registered: Jul 2007
Distribution: Slackware Linux
Posts: 512

Rep: Reputation: Disabled
Quote:
Originally Posted by Paulo2 View Post
Thanks for the advice. I usually always protect vars with double quotes, this doesn't help avoiding problems?
Not really. Let's say I populate a directory with two files named "foo" and "bar\nbaz", that is, "bar<newline>baz", and I have a script with the following contents:

Code:
#!/bin/sh
for f in `ls`; do echo rm -fr "$f"; done
Running the script yields:

Code:
rm -fr bar
rm -fr baz
rm -fr foo
I'm not making things up. I just tested this.
 
Old 07-27-2013, 04:20 AM   #29
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,014

Rep: Reputation: 146Reputation: 146
Quote:
Originally Posted by GazL View Post
/tmp is meant to be used as transient workspace for running tasks. Anything that leaves stuff in /tmp when it ends is 'broken'.
...
though anything that is going to use a large amount of disk space like that really should be assigned it's own dedicated space so as not to impact the rest of the system and/or its users), but it's more common that a large amount of data collecting in /tmp is just a sign of abuse of the filesystem.
...
Abuse? Criminal offense? Seriously!
We were talking about /tmp usage comparable to the main memory size. As the main memory size is usually 0.1~1% of the disk size, so you mean filling up 0.1~1% of the disk space is just a sign of abuse?
 
Old 07-27-2013, 04:29 AM   #30
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,014

Rep: Reputation: 146Reputation: 146
Quote:
Originally Posted by rkelsen View Post
Yes. Why don't you do that?
Because I am no mathematician. I don't create a problem just for solving it.

Quote:
Originally Posted by rkelsen View Post
Well I did also say /root... But you seem to have ignored that for some reason.
Not really. I just wondered what /home has to do with SlackBuild. Even /usr/src is a better place to compile software than /root because it's bad practice to mount /root on a separate filesystem but it's the contrary for /usr/src.

Quote:
Originally Posted by rkelsen View Post
Regardless, I often edit out the 'root only' commands in a SlackBuild to get what I want as a regular user. And you don't have to use SlackBuild scripts for everything, you know...
Good to know you are a mathematician. I admire people with advanced brains.
 
  


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/Novell 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


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

Main Menu
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