LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Command to clean tmp at shutdown (https://www.linuxquestions.org/questions/slackware-14/command-to-clean-tmp-at-shutdown-4175470934/)

GazL 07-27-2013 04:47 AM

Quote:

Originally Posted by guanx (Post 4997768)
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?

The only one who has mentioned "Criminal offense" is yourself.
abuse (verb): to use wrongly or improperly. My use of the word was correct.

rkelsen 07-27-2013 08:54 AM

Quote:

Originally Posted by guanx
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.

ok. you have officially lost me. I'm out.

qweasd 07-27-2013 11:29 AM

Quote:

Originally Posted by rng (Post 4996864)
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

This seems to work. Beware of glob and bash loops: you have to be super-duper sure it treats filenames with spaces, tabs, and new lines right. Would this be OK, I wonder?

Code:

/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -delete
Nevermind: non-empty folders get skipped.

STDOUBT 07-27-2013 02:50 PM

I have a 250GB hard drive:
20GB /root
1GB swap
1.5GB tmpfs (default)
remaining GB /home

Sometimes I remove /tmp/SBo/ but everything else in it remains. Gives me a quick view of the extra stuff I have installed. That and my /home/Slackbuilds directory. Doesn't get in my way a bit.

irgunII 07-27-2013 10:15 PM

Quote:

Originally Posted by rkelsen (Post 4997619)
(about my question regarding deleting SBo in /tmp)
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.

Thanks, done and everything's working normally still and I gained 13GB, heh.

brianL 07-28-2013 07:10 AM

Quote:

Originally Posted by irgunII (Post 4998169)
Thanks, done and everything's working normally still and I gained 13GB, heh.

Similar here. Disk usage gone down from 67% to 51%.

rkfb 07-29-2013 01:04 PM

Quote:

Originally Posted by vdemuth (Post 4997305)
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

Maybe better in rc.local_shutdown which is called by rc.6

Paulo2 08-01-2013 08:43 AM

Quote:

Originally Posted by rg3 (Post 4997758)
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.

You are convincing me that quotes doesn't work always :) but how did you create that file with new line in the name?
I tried touch foo\nbar , touch foo\\nbar , touch "foo\\nbar" , touch "foo\nbar" , without success.


I was looking at the ls options again, and there is this option "-Q" (and --quoting-style=WORD) that I think is very
usefull, it encloses the names with spaces in double (or single) quotes.


Sorry if this is a little bit off-topic.

qweasd 08-01-2013 10:37 AM

Quote:

Originally Posted by Paulo2 (Post 5000946)
You are convincing me that quotes doesn't work always :) but how did you create that file with new line in the name?

Code:

touch $'foo\nbar'

Paulo2 08-01-2013 11:26 AM

Quote:

Originally Posted by qweasd (Post 5001007)
Code:

touch $'foo\nbar'

didn't work :scratch:
Code:

paulo@paulo:~/Isos$ touch $'foo\nbar'
paulo@paulo:~/Isos$ v
total 0
-rw-r--r-- 1 paulo users 0 Ago  1 13:04 foo\nbar
paulo@paulo:~/Isos$ for i in `ls`;do echo rm -rf "$i";done
rm -rf foo\nbar
paulo@paulo:~/Isos$ for i in `ls`;do echo rm -rf $i;done
rm -rf foo\nbar

But if I type directly with tab auto-completing, the "\n" appears like a real new line
Code:

paulo@paulo:~/Isos$ rm 'foo
bar'

Well, now I know that there are characters that quotes doesn't handle, I will be more careful.

guanx 08-01-2013 05:53 PM

Quote:

Originally Posted by GazL (Post 4997332)
... 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)

You forgot the I/O bandwidth, CPU power to deal with these data, etc. "Not to impact the rest of the system" is simply impossible.

Quote:

Originally Posted by GazL (Post 4997332)
but it's more common that a large amount of data collecting in /tmp is just a sign of abuse of the filesystem.

I repeat my last post: Filling the filesystem by 0.1% is far from abuse. Storage is there to be filled, money is there to be spent, life is there to be lived. If anyone don't agree, don't live.

Quote:

Originally Posted by GazL (Post 4997332)
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 ...

Who told you this? I've never heard of this nonsense before.

guanx 08-01-2013 05:55 PM

Quote:

Originally Posted by rkfb (Post 4999023)
Maybe better in rc.local_shutdown which is called by rc.6

Yes that's better. And a mkfs on startup is the best, if /tmp is on a separate filesystem but not tmpfs.

qweasd 08-01-2013 09:13 PM

Paulo2, may be my bash-fu is lacking, but I don't see a way around it without find -print0, which is guaranteed to work at least on ext, since the latter forbids zero chars in file names. OTOH, parsing the output of /bin/ls seems like a rather nasty problem, because it separates file names with new lines, and file names may contain new lines, spaces, tabs, quotes, and what have you.

rg3 08-02-2013 06:00 AM

Quote:

Originally Posted by Paulo2 (Post 5000946)
but how did you create that file with new line in the name?

Normally by accident. :-)

For example, you can create them with:

Code:

touch 'foo
bar'

Or from a program in some programming language. In Python it's pretty simple:

Code:

python -c 'open("bar\nbaz", "w")'
And yeah, sorry for the off-topic...


All times are GMT -5. The time now is 10:26 PM.