what to do with files in /tmp
My /tmp folder currently has 3,5 Gb! I just found this out when I was browsing in my computer, to see what takes up so much space.
Ok, so this should theoretically be a folder where programs store temporary files, and delete them automatically after a while, right? Well, in a folder in /tmp called kde-myusername I currently have, stored as *.tmp files: - most of the stuff I previewed in Ark, athough the archives they were originating from have been deleted a few months ago - pictures, pdf's and web pages that I viewed in konqueror - all log files of konqueror crashes - about 20 files called amarok followed by various letters and numbers, containing only Quote:
- and, what takes up most space, all the video clips I have stored on cd's that I have ever viewed using various movie players, mostly kaffeine. There are mostly only parts of the clips. This are probably more newbie questions, but still I am asking it here. 1. Does it HAVE to store all these files? 2. Can I configure it to delete what it doesn't need anymore automatically? Or do I have to delete the files manually every time? If so, what do I do, just delete every *.tmp file there? 3. I also have 2 .xkm files in there. What are these used for? Any help/info is appreciated. Thank you for reading this. |
Quote:
24/7 you'll have to start thinking about house-keeping yourself... Answering #1) No, it doesn't. #2) A script run from a cron-job will be fine. I'd suggest something that makes sure the files you're about to delete aren't being used anymore. find -atime +7 -type f -exec rm -rf {} \; will be fine. #3) no idea - pass. Did you ask google, our best friend? Cheers, Tink |
Thanks for the quick reply.
No, I don't keep my machine up 24/7. I close it every night, but it doesn't seem to clean /tmp at a reboot or shutdown. I was thinking about cron too, if there is no other way. One more question. What do the parameters after rm do? ( -rf {} \; ) the man pages don't offer much info. Isn't there a program that does this at boot time or shutdown, when no programs that might use it are running? Also, I'm a bit afraid to remove everything in temp, even the files that haven't been used for a while, because of numerous people who claim that they deleted a file in /tmp and Linux got messed up, and none ever figured out why that happened. Maybe I'm just paranoid. I want to also find out first why it still keeps files last accessed over 6 months ago. The .xkm file, according to dear ol' google is a "compiled keymap file", generated by a program called xkbcomp, which I don't seem to have installed. Any ideas anyone? |
I had the same problem. I added a line to my shutdown script:
rm -rf /tmp/* /var/tmp/* This gets rid of all 'visible' files whenever the machine is shut down. I have had no problems with deleting it all. Regards, Bill |
Thanks, I'll just put them in the trash and see what happens, then if nothing bad happens, I'll just write a cron job or something.
|
Quote:
|
ok, thanks, I'll just leave /var/tmp alone, as it doesn't occupy much space...
My main concern is just /tmp. As long as nothing can go wrong there, it's ok. |
Quote:
Think of it as grouped like this. -exec tells find to run command & params against anything it found; {} is the placeholder for the path&name of the matching results; \; is an escaped ; that terminates the exec, the \ is there so the shell doesn't think it's a command-separator. Quote:
kind of activity to the discretion of the root user; Debian (and most of its derivates) will have an /etc/init.d/bootclean that's run during startup after mounting the file-systems. It's been too long that I last actively used any dead-rat based distro to be able to tell you how they do it :} and I can't get to the SuSE machines at work from home ;} Cheers, Tink |
Thanks again.
I looked in /etc/init.d and it does have a script called boot.clean, and, according to my low knowledge of shell scripting, it does remove some of the files in /tmp, but not all, specifically not the ones in /tmp/kde-dark (where dark is my username), or /tmp/kde-root (but that folder is mostly empty anyway,as I don't spend much time as root). Anyway, for the ones curious enough, and patient enough to read, this is what that script contains: Quote:
While trying to find an answer for myself, I found /etc/init.d/README, which has this statement: " After system startup, /sbin/init will normally switch on the default run level given in /etc/inittab. It calls the run level master script /etc/init.d/rc to start or stop services provided by the other scripts under /etc/init.d/. Both scripts, then boot level master script /etc/init.d/boot and the the run level master script /etc/init.d/rc starts all other boot or runlevel scripts either sequential or partial parallel within their dependencies order." I took a fast look in all the scripts/files mentioned, but none seemed to execute boot.cleanup. I will look more in detail in them, taking the scripts line by line to understand how it works one of the following days. I also think I am an idiot for not checking when boot.cleanup was last accessed before opening it with kwrite. But I'll look if it will have been accessed when I will reboot my computer. Anyway, does anyone know a quick answer to this? What do I have to edit for a script to be executed at startup? Sorry for the long post. Any ideas anyone? |
Quote:
Reals rc scripts are in directories named rc2.d rc3.d etc, and starts with either an uppercase S or an uppercase K. |
Quote:
|
check if this line (clear_tmp_enable="YES")is in /etc/rc.conf
you can add a command to crontab to clear the /tmp: */120 * * * * root cd /tmp;rm * |
Quote:
Never do that. Edit: I hope everyone understand why, as I had no reaction to this post ... |
Quote:
Quote:
But thanks, this is an interesting concept I haven't learned anything about so far. I could find other uses for a tmpfs... Off topic, does anyone have a good howto link? |
Quote:
Quote:
You can put a 700MB file in tmpfs with 512MB of RAM, as tmpfs is backed by virtual memory, but you won't have any improvement because the system would paginate quite a lot during the file creation. |
Thanks again everyone.
I think I got it, but I stil have one last question. Here's what I have done, it can also act as a small howto for others who have this problem: - Made a shell script called cleartmp.sh : Quote:
- Created a symbolic link in /etc/init.d/rc5.d: Quote:
|
jlliagre why the never do that comment?
|
Quote:
Code:
*/120 * * * * root cd /tmp;rm * 2) "cd /tmp" return value is not checked, if for some (unlikely and odd) reason, /tmp doesn't exists at the moment the command is run, the rm will remove everything in the user's home directory (unless the shell quit after the failed cd, not sure if bash does that). 3) the rm command doesn't check if the files it is going to remove are in use, and even if it would, that wouldn't be enough as even usused files can be expected to stay for an ongoing process that will open it later. This rm command would only be safe in a quiet system, with all services and applications stopped, ideally in single user mode. |
All times are GMT -5. The time now is 09:51 PM. |