Knowledgebase

Cleaning /tmp in cPanel

Posted by kshazad86, 04-01-2012, 09:08 AM
So far I have the following ways of cleaning up the tmp folder safely: At the moment I have the following files consuming the most space in /tmp folder, can someone let me know if they are safe to delete?

Posted by Patrick, 04-01-2012, 09:11 AM
You don't need to restart MySQL when clearing out the tmp directory - just leave the mysql.sock file alone. How large is your /tmp partition anyway? If it's not large enough, as in a few GB, you could move the /tmp directory to a larger partition using symlinks and what not. Another option would be to create a cron job that removes impatt* files from the /tmp directory every hour or so. (The impatt* files are safe to delete.)

Posted by kshazad86, 04-01-2012, 09:13 AM
Thanks, Yea, the tmp partition isn't actually that big, only 485Mb, but I'm not to keen on increasing this as it may mess things up unless there is a nice and easy way to achieve this. I can setup a cron job no problem, just wanted to make sure that deleting impatt* files wont cause any errors/problems.

Posted by Patrick, 04-01-2012, 09:16 AM
It's totally fine to remove the impatt* files. They are supposed to be removed by Horde anyway but sometimes for whatever reason some get left behind. It has to do with attachments, but removing them isn't going to interfere with Horde or anything like that. People will still be able to access the attachments, etc. Strictly cache related.

Posted by kshazad86, 04-01-2012, 09:18 AM
ok, but what about the directory './' located inside the tmp folder (owned by root) and appears to take up some space?

Posted by Server Management, 04-01-2012, 09:23 AM
You can use tmpwatch with a cron however I would recommend that you get server management or else I can see you screwing that server up I recommend you resize this to at least 2GB however 10GB is better...

Posted by Patrick, 04-01-2012, 09:25 AM
The ./ directory is the same directory you're in, in this case it would be the /tmp directory although the file size doesn't add up. At least that's how it appears on my Linux box: [dev@vpn ~]$ cd /tmp [dev@vpn tmp]$ cd ./ [dev@vpn tmp]$ pwd /tmp [dev@vpn tmp]$ I wouldn't try and remove it, bad things would probably happen.

Posted by kshazad86, 04-01-2012, 09:30 AM
ok, there is only one other file that I need to know about and that is php* (e.g. php49IdZH) file in tmp folder usually owned by a user on the server. Am I safe to delete these?

Posted by Server Management, 04-01-2012, 09:33 AM
Setup tmpwatch or else you will be deleting these files daily sometimes hourly since your /tmp is so small... Randomly going into your /tmp and deleting files your asking for problems as the file in question might actually be getting used when you delete it at least with tmpwatch it deletes depending upon last access time, etc

Posted by Patrick, 04-01-2012, 09:33 AM
Yep. The php* files are also cache related. Some of them are from ImageMagick or GD when users have images resized within their PHP applications. Totally safe to delete. (Leave the sess* files alone though. Those are important to users who are still logged into their sites.)

Posted by kshazad86, 04-01-2012, 09:35 AM
ok, but deleting the sess* files shouldnt really be a problem right, since if users are logged in, they'll be kicked out and they can log back in?

Posted by Patrick, 04-01-2012, 09:36 AM
Sure but that's kind of annoying for them? The sess files are very small anyway, it would be worth it to leave them alone but nothing terrible will happen if you do remove them.

Posted by Server Management, 04-01-2012, 09:38 AM
I would get slightly cheesed aswell

Posted by kshazad86, 04-01-2012, 09:39 AM
True but I wouldnt be randomly deleting files, you can use the following command to show the files using up the most space as well as their last access time, which would also tell you if the file is important or not:

Posted by Server Management, 04-01-2012, 09:41 AM
You wouldnt need to with tmpwatch as it cleans using a cronjob. You seriously need your /tmp resized to something bigger or else it'll be getting full in no time.

Posted by kshazad86, 04-01-2012, 12:31 PM
Found a nice and easy tutorial on this: http://adamstechblog.com/category/cpanel/ tmp has now been updated to 2GB.

Posted by brianoz, 04-03-2012, 04:03 AM
If you're doing that sort of find to remove files, you should also use the -mtime option to reduce chance of removing active files: This variant will only remove files more than a day or so old. The reordering of the options may be slightly faster if you have a really big /tmp.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Stormondemand Issues (Views: 612)
Unixshell Down? (Views: 643)
ASP.NET trust level (Views: 650)
Cobranded (Views: 608)
How does Cloud work ? (Views: 621)


Language:

Client Login

Email

Password

Remember Me

Search