<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>/proc/sys/net/blog &#187; mysql</title>
	<atom:link href="http://momotonic.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://momotonic.com</link>
	<description>rants, tutorials and documents about everything server related</description>
	<lastBuildDate>Tue, 14 Jul 2009 15:55:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>/tmp clean-up script modification, sessions dying with PHP</title>
		<link>http://momotonic.com/2008/11/28/tmp-clean-up-script-modification-sessions-dying-with-php/</link>
		<comments>http://momotonic.com/2008/11/28/tmp-clean-up-script-modification-sessions-dying-with-php/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 13:11:18 +0000</pubDate>
		<dc:creator>Mo</dc:creator>
				<category><![CDATA[cpanel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql.sock]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tmp]]></category>
		<category><![CDATA[cleanup]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[timeout]]></category>
		<category><![CDATA[tmpcleanup]]></category>

		<guid isPermaLink="false">http://momotonic.com/?p=19</guid>
		<description><![CDATA[It seems there there was a little flaw in the script that I wrote a while ago, any PHP sessions on the server will timeout/die after 1 hour if you run that as an hourly cronjob, I have made a small modification to the script.
The only small modification is that now, it deletes all sess_* [...]]]></description>
			<content:encoded><![CDATA[<p>It seems there there was a little flaw in the script that I wrote a while ago, any PHP sessions on the server will timeout/die after 1 hour if you run that as an hourly cronjob, I have made a small modification to the script.</p>
<p>The only small modification is that now, it deletes all <code>sess_*</code> files that have not been accessed for 5 days therefore are probably just sitting there and never going to be used again, the rest remain deleted because it&#8217;s failed uploads/etc that will never be used again.</p>
<p><code><br />
#!/bin/bash</p>
<p># Change directory to /tmp<br />
cd /tmp</p>
<p># Clean up trash left by Gallery2<br />
ls | grep '[0-9].inc*' | xargs rm -fv</p>
<p># Clean up PHP temp. session files<br />
find /tmp -atime +5 -name 'sess_*' -print | xargs rm -fv</p>
<p># Clean up dead vBulletin uploads<br />
ls | grep 'vbupload*' | xargs rm -fv</p>
<p># Clean up failed php uploads<br />
ls | grep 'php*' | xargs rm -fv</p>
<p># Clean up failed ImageMagick conversions.<br />
ls | grep 'magick*' | xargs rm -fv<br />
</code></p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://momotonic.com/2008/11/28/tmp-clean-up-script-modification-sessions-dying-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cleaning up /tmp directory on busy cPanel web hosting servers</title>
		<link>http://momotonic.com/2008/11/27/cleaning-up-tmp-directory-on-busy-cpanel-web-hosting-servers/</link>
		<comments>http://momotonic.com/2008/11/27/cleaning-up-tmp-directory-on-busy-cpanel-web-hosting-servers/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 02:22:58 +0000</pubDate>
		<dc:creator>Mo</dc:creator>
				<category><![CDATA[cpanel]]></category>
		<category><![CDATA[error 22]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql.sock]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tmp]]></category>
		<category><![CDATA[full]]></category>
		<category><![CDATA[uploads]]></category>

		<guid isPermaLink="false">http://momotonic.com/?p=17</guid>
		<description><![CDATA[Usually, the /tmp directory is one of the frequently accessed directories, temp files of MySQL, PHP and other applications are placed and often if processes die, left over.  Uploads using PHP are always uploaded to the /tmp directory till they are complete, if you have some dying processes, you will end up with a [...]]]></description>
			<content:encoded><![CDATA[<p>Usually, the <code>/tmp</code> directory is one of the frequently accessed directories, temp files of MySQL, PHP and other applications are placed and often if processes die, left over.  Uploads using PHP are always uploaded to the <code>/tmp</code> directory till they are complete, if you have some dying processes, you will end up with a filled <code>/tmp</code> directory which is hell.</p>
<p>Why? Because MySQL leaves and uses it&#8217;s temporary files in <code>/tmp</code>, and if there is no space in there, queries will start failing.  Uploads from PHP or Perl are placed in there till the upload process is over, they cannot be further placed there because there is no more space left.  So far, we have failing MySQL &#038; inability to upload complete PHP files, <i>system administrator hell</i>.</p>
<p>Easy fix, you might say?  Just a simply <code>rm -rf /</code> should take care of it?  Nope.  Try that, have fun trying to fix the sockets you deleted, specifically applications that depend on the <i>mysql.sock</i> placed in your <i>/tmp</i> directory, things just got worse.  In case you actually did delete everything, just restart the services, they should re-appear, if they don&#8217;t, they should be somewhere else and you have to create a symbolic link using <code>li</code>, MySQL&#8217;s socket is usually located at <code>/var/lib/mysql/mysql.sock</code>.</p>
<p>The best way is to either have a script that cleans it up hourly if you know what usually fills it up or manually run <code>ls -alhS /tmp | head</code> and looking what&#8217;s causing the problem and how to avoid it in the future, I have developed a script that I run on multiple servers with no problems at the moment.  It takes care of the most trash caused on a cPanel server</p>
<p><code>#!/bin/bash</p>
<p># Change directory to /tmp<br />
cd /tmp</p>
<p># Clean up trash left by Gallery2<br />
ls | grep '[0-9].inc*' | xargs rm -fv</p>
<p># Clean up PHP temp. session files<br />
ls | grep 'sess_*' | xargs rm -fv</p>
<p># Clean up dead vBulletin uploads<br />
ls | grep 'vbupload*' | xargs rm -fv</p>
<p># Clean up failed php uploads<br />
ls | grep 'php*' | xargs rm -fv</p>
<p># Clean up failed ImageMagick conversions.<br />
ls | grep 'magick*' | xargs rm -fv</code></p>
<p>That usually is enough, my suggestion is to have that run as a cronjob every hour, but I&#8217;m not going in detail on how to do that, because if you don&#8217;t know how to setup a cronjob, perhaps you shouldn&#8217;t be messing around in <code>/tmp</code> directories and deleting stuff on the first place!</p>
<p><b>Update: This script is faulty and will cause you a lot of problems with PHP sessions, please read more information and read the new one <a href="http://momotonic.com/2008/11/28/tmp-clean-up-script-modification-sessions-dying-with-php/">here</a></b></p>
]]></content:encoded>
			<wfw:commentRss>http://momotonic.com/2008/11/27/cleaning-up-tmp-directory-on-busy-cpanel-web-hosting-servers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
