<?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>SysAdmin Valley &#187; mini how-to</title>
	<atom:link href="http://www.sysadminvalley.com/tag/mini-how-to/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sysadminvalley.com</link>
	<description>I might as well write this stuff down so I remember it tomorrow</description>
	<lastBuildDate>Tue, 18 May 2010 17:22:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Excluding files in FIND results</title>
		<link>http://www.sysadminvalley.com/2010/03/09/excluding-files-in-find-results/</link>
		<comments>http://www.sysadminvalley.com/2010/03/09/excluding-files-in-find-results/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 19:31:09 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=195</guid>
		<description><![CDATA[Find is one of my favorite little tools under linux.  It helps me &#8220;find&#8221; almost anything, I can find files older than a certain date, newer than a certain date, modified on a certain date.  I can find files that have a certain name, or match a part of a name, file extension.  Once I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Find is one of my favorite little tools under linux.  It helps me &#8220;find&#8221; almost anything, I can find files older than a certain date, newer than a certain date, modified on a certain date.  I can find files that have a certain name, or match a part of a name, file extension.  Once I&#8217;ve found what I&#8217;ve been looking for I can have find do something with those files like delete them or gzip them.</p>
<p>My latest &#8220;find&#8221; with the find command came about because on one of my JBoss servers I wrote a simple script that looks for log files older than 15 days and deletes them and looks for other log files older than 61 minutes and compresses them with gzip.</p>
<blockquote><p>#!/bin/bash<br />
LOGS=/usr/local/jboss/server/all/log/<br />
#delete all logs older than 37 days<br />
find $LOGS -mtime +15 | xargs rm -rf<br />
# gzip files last modify at least 1 hour ago<br />
find $LOGS -mmin +61 | xargs gzip</p></blockquote>
<p>Our JBoss setup automatically writes new logs to server.info.log and server.error.log, then every every hour it renames the INFO and ERROR log to the current date + hour, so server.info.log would be changed to server.info.log.2010-03-09-13 for today at 2pm to roll out the 1pm logs.</p>
<p>The problem I came across in my script was with my server.error.log file.  If an error hasn&#8217;t been written to the server.error.log file during that hour, it wasn&#8217;t going to rotate an empty error log.  Since the file hadn&#8217;t been touched/updated/modified in over 61 minutes, my script came along and gzipped it, at this point JBoss then had a problem because the error log was missing and didn&#8217;t create a new one.</p>
<p>So what I needed to do was to find all the files that matched the criteria, but exclude the server.info.log and server.error.log and here is my final script.</p>
<blockquote><p>#!/bin/bash<br />
LOGS=/usr/local/jboss/server/all/log/<br />
INFOLOG=&#8221;server.info.log&#8221;<br />
ERRORLOG=&#8221;server.error.log&#8221;<br />
#delete all logs older than 37 days<br />
find $LOGS -mtime +15 -not -name &#8220;$INFOLOG&#8221; -not -name &#8220;$ERRORLOG&#8221; | xargs rm -rf<br />
# gzip files last modify at least 1 hour ago<br />
find $LOGS -mmin +61 -not -name &#8220;$INFOLOG&#8221; -not -name &#8220;$ERRORLOG&#8221; | xargs gzip</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2010/03/09/excluding-files-in-find-results/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Uppercase to Lowercase (and vice-versus)</title>
		<link>http://www.sysadminvalley.com/2009/07/06/converting-uppercase-to-lowercase-and-vice-versus/</link>
		<comments>http://www.sysadminvalley.com/2009/07/06/converting-uppercase-to-lowercase-and-vice-versus/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 19:01:18 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=100</guid>
		<description><![CDATA[I love bash and scripting!!!  There&#8217;s almost nothing you can&#8217;t do with a shell script that would take me forever if I had to write an app to do the same.  So here&#8217;s another quick tip.  To convert text in a file from uppercase to lowercase use the following: cat FILENAME &#124; tr &#8220;[:upper:]&#8221; &#8220;[:lower:]&#8220; [...]]]></description>
			<content:encoded><![CDATA[<p>I love bash and scripting!!!  There&#8217;s almost nothing you can&#8217;t do with a shell script that would take me forever if I had to write an app to do the same.  So here&#8217;s another quick tip.  To convert text in a file from uppercase to lowercase use the following:</p>
<blockquote><p>cat FILENAME | tr &#8220;[:upper:]&#8221; &#8220;[:lower:]&#8220;</p></blockquote>
<p>Or to go from lowercase to uppercase:</p>
<blockquote><p>cat FILENAME | tr &#8220;[:lower:]&#8221; &#8220;[:upper:]&#8220;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2009/07/06/converting-uppercase-to-lowercase-and-vice-versus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using seq to generate a list of numbers</title>
		<link>http://www.sysadminvalley.com/2009/06/30/using-seq-to-generate-a-list-of-numbers/</link>
		<comments>http://www.sysadminvalley.com/2009/06/30/using-seq-to-generate-a-list-of-numbers/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 20:06:56 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=96</guid>
		<description><![CDATA[Another quick hint.  While working on a server I needed to bring up a whole lot of IP addresses (200 to be exact).  If I really wanted to I could bring them all up like this: ifconfig eth0:2 1.1.1.2 netmask 255.255.255.0 up ifconfig eth0:3 1.1.1.3 netmask 255.255.255.0 up and so on to&#8230;.. ifconfig eth0:200 1.1.1.200 [...]]]></description>
			<content:encoded><![CDATA[<p>Another quick hint.  While working on a server I needed to bring up a whole lot of IP addresses (200 to be exact).  If I really wanted to I could bring them all up like this:</p>
<blockquote><p>ifconfig eth0:2 1.1.1.2 netmask 255.255.255.0 up<br />
ifconfig eth0:3 1.1.1.3 netmask 255.255.255.0 up<br />
and so on to&#8230;..<br />
ifconfig eth0:200 1.1.1.200 netmask 255.255.255.0 up</p></blockquote>
<p>Well, I&#8217;m always looking for an easier way, so I turned to my friend BASH and a tool called SEQ.  SEQ will give you a sequence of numbers.  For example if you just wanted 10 numbers you could do the following:</p>
<blockquote><p>[matt@localhost ~]$ seq 5<br />
1<br />
2<br />
3<br />
4<br />
5</p></blockquote>
<p>So for this task I needed to bring up IP addresses from 2 through 254.  Running &#8220;seq 2 254&#8243; will give me a sequence from 2 to 254, I need more than just to have a list of numbers, I actually need to use them, so here&#8217;s the syntax I used to use the numbers to bring up each of the interfaces</p>
<blockquote><p>for i in $(seq 2 254)<br />
do<br />
ifconfig eth0:$i 1.1.1.$i netmask 255.255.255.0 up<br />
done</p></blockquote>
<p>Obviously in the above example, you would substitute the sequence you want to use and the IP subnet you want to use.  Also, this syntax would put 1.1.1.2 on sub-interface eth0:2, 1.1.1.3 on sub-interface eth0:3, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2009/06/30/using-seq-to-generate-a-list-of-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Curl requests by binding to different IP address</title>
		<link>http://www.sysadminvalley.com/2009/06/29/curl-requests-by-binding-to-different-ip-address/</link>
		<comments>http://www.sysadminvalley.com/2009/06/29/curl-requests-by-binding-to-different-ip-address/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 15:29:37 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=91</guid>
		<description><![CDATA[From time to time I need to use Curl to test websites and sometimes I need to make the request come from a different IP address, other than the server&#8217;s default IP.  Note, the IP address you use must be active on your server.  To do this, use the following syntax: curl --interface xxx.xxx.xxx.xxx -s [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time I need to use Curl to test websites and sometimes I need to make the request come from a different IP address, other than the server&#8217;s default IP.  Note, the IP address you use must be active on your server.  To do this, use the following syntax:</p>
<blockquote>
<pre>curl --interface xxx.xxx.xxx.xxx -s http://www.sysadminvalley.com</pre>
</blockquote>
<p>Make sure that you substitute xxx.xxx.xxx.xxx with the IP address you want to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2009/06/29/curl-requests-by-binding-to-different-ip-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a self-signed SSL Certificate</title>
		<link>http://www.sysadminvalley.com/2009/02/17/creating-a-self-signed-ssl-certificate/</link>
		<comments>http://www.sysadminvalley.com/2009/02/17/creating-a-self-signed-ssl-certificate/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 15:16:24 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=72</guid>
		<description><![CDATA[For this you will need the openssl package.  First we want to start by generating a private key. root@localhost# openssl genrsa -out www.mydomain.com.key 1024 Generating RSA private key, 1024 bit long modulus &#8230;&#8230;&#8230;&#8230;.++++++ &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..++++++ e is 65537 (0&#215;10001) Then, we need to generate the certificate request and fill in the appropriate information.  Make sure that [...]]]></description>
			<content:encoded><![CDATA[<p>For this you will need the openssl package.  First we want to start by generating a private key.</p>
<blockquote><p>root@localhost# openssl genrsa -out www.mydomain.com.key 1024<br />
Generating RSA private key, 1024 bit long modulus<br />
&#8230;&#8230;&#8230;&#8230;.++++++<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..++++++<br />
e is 65537 (0&#215;10001)</p></blockquote>
<p>Then, we need to generate the certificate request and fill in the appropriate information.  Make sure that the &#8220;Common Name&#8221; matches the domain you want to protect via SSL, so if you domain was www.mydomain.com, use that.  If you wanted to protect mydomain.com (without the www.) then use that.</p>
<blockquote><p>root@localhost# openssl req -new -key www.mydomain.com.key -out www.mydomain.com.csr<br />
You are about to be asked to enter information that will be incorporated<br />
into your certificate request.<br />
What you are about to enter is what is called a Distinguished Name or a DN.<br />
There are quite a few fields but you can leave some blank<br />
For some fields there will be a default value,<br />
If you enter &#8216;.&#8217;, the field will be left blank.<br />
&#8212;&#8211;<br />
Country Name (2 letter code) [GB]:<br />
State or Province Name (full name) [Berkshire]:<br />
Locality Name (eg, city) [Newbury]:<br />
Organization Name (eg, company) [My Company Ltd]:<br />
Organizational Unit Name (eg, section) []:<br />
Common Name (eg, your name or your server&#8217;s hostname) []:www.mydomain.com<br />
Email Address []:email@mydomain.com</p>
<p>Please enter the following &#8216;extra&#8217; attributes<br />
to be sent with your certificate request<br />
A challenge password []:<br />
An optional company name []:</p></blockquote>
<p>Next, generate the self-signed certificate. You can specify the number of days the cert is valid for.</p>
<blockquote><p>root@localhost# openssl x509 -req -days 365 -in www.mydomain.com.csr -signkey www.mydomain.com.key -out www.mydomain.com.crt<br />
Signature ok<br />
subject=/C=/ST=/L=/O=/CN=www.mydomain.com/emailAddress=email@mydomain.com<br />
Getting Private key</p></blockquote>
<p>Next, move the certificate and keyfile into apache&#8217;s SSL directory.</p>
<blockquote><p>mv www.mydomain.com.key /etc/httpd/conf/ssl.key/<br />
mv www.mydomain.com.crt /etc/httpd/conf/ssl.crt/</p></blockquote>
<p>Finally, we configure our SSL virtual host in Apache.  The simplest way to do this is to copy the virtual host for the site you want to make SSL, then add/change the following bits.</p>
<blockquote><p>&lt;VirtualHost 192.168.1.100:443&gt;<br />
&#8230;<br />
SSLEngine on<br />
SSLCertificateFile /etc/httpd/conf/ssl.key/www.mydomain.com.key<br />
SSLCertificateKeyFile /etc/httpd/conf/ssl.crt/www.mydomain.com.crt<br />
&#8230;<br />
&lt;/VirtualHost&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2009/02/17/creating-a-self-signed-ssl-certificate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search and Replace for multiple files</title>
		<link>http://www.sysadminvalley.com/2009/02/02/search-and-replace-for-multiple-files/</link>
		<comments>http://www.sysadminvalley.com/2009/02/02/search-and-replace-for-multiple-files/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 17:17:10 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=68</guid>
		<description><![CDATA[Here is a quick tip to help doing search and replace in multiple files.    You may need to change to fit your needs. for file in `ls *.php` do sed -e &#8216;s/Copyright 2008/Copyright 2009/&#8217; &#8220;$file&#8221; &#62; tmp_file mv -f tmp_file &#8220;$file&#8221; done What this does is get&#8217;s a list of all php files in the [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick tip to help doing search and replace in multiple files.    You may need to change to fit your needs.</p>
<blockquote><p>for file in `ls *.php`<br />
do<br />
sed -e &#8216;s/Copyright 2008/Copyright 2009/&#8217; &#8220;$file&#8221; &gt; tmp_file<br />
mv -f tmp_file &#8220;$file&#8221;<br />
done</p></blockquote>
<p>What this does is get&#8217;s a list of all php files in the current directory, puts them in a loop with a variable called FILE, then does a sed search and replace calling the new file tmp_file and moving the temp file back in place.  If you wanted to do it for all files including in subdirectories, you could substitute:</p>
<blockquote><p>ls *.php</p></blockquote>
<p>with:</p>
<blockquote><p>find ./ -name &#8220;*.php&#8221;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2009/02/02/search-and-replace-for-multiple-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Another must have MySQL tool</title>
		<link>http://www.sysadminvalley.com/2009/01/06/another-must-have-mysql-tool/</link>
		<comments>http://www.sysadminvalley.com/2009/01/06/another-must-have-mysql-tool/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 21:19:12 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=39</guid>
		<description><![CDATA[As you probably gather I do quite a bit of MySQL work, in fact over the years I&#8217;ve sort of become the MySQL DBA where I work.  From time to time we&#8217;ve had issues where our MySQL server just aren&#8217;t performing as well as they could.  Sure we could hire an expensive consultant, but I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>As you probably gather I do quite a bit of MySQL work, in fact over the years I&#8217;ve sort of become the MySQL DBA where I work.  From time to time we&#8217;ve had issues where our MySQL server just aren&#8217;t performing as well as they could.  Sure we could hire an expensive consultant, but I&#8217;ve come across this tool called <a href="http://wiki.mysqltuner.com/MySQLTuner" target="_blank">MySQLTuner</a> which gives me the ability to see what settings I should tune.</p>
<p>It&#8217;s a simple perl script and to use it is really easy.  First, download the script to your linux server, change it to be executable, then run it</p>
<blockquote><p>wget http://mysqltuner.com/mysqltuner.pl<br />
chmod 0700 mysqltuner.pl<br />
./mysqltuner.pl</p></blockquote>
<p>You&#8217;ll get a great one page output which gives you some great detail about what&#8217;s going on, and what settings can be used in your my.cnf file.  One word of caution, make sure you backup your my.cnf before making changes, and you should also spend some time learning what the values mean.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2009/01/06/another-must-have-mysql-tool/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Useful MySQL Queries</title>
		<link>http://www.sysadminvalley.com/2009/01/05/useful-mysql-queries/</link>
		<comments>http://www.sysadminvalley.com/2009/01/05/useful-mysql-queries/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 21:10:54 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=34</guid>
		<description><![CDATA[I recently had the need to do some troubleshooting on some of my larger MySQL databases.  It seems one of our developers turned off innodb_file_per_table = 1 in the /etc/my.cnf.  This feature tells MySQL to for every Innodb table to create a separate file, if it&#8217;s not turned on, it stores all the tables in [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had the need to do some troubleshooting on some of my larger MySQL databases.  It seems one of our developers turned off <em><strong>innodb_file_per_table = 1</strong></em> in the <em><strong>/etc/my.cnf</strong></em>.  This feature tells MySQL to for every Innodb table to create a separate file, if it&#8217;s not turned on, it stores all the tables in 1 large file.  This can be extremely painful by itself to maintain as it grows.  Anyway, I had the need to do a little research on database and table sizes and came across a post by Peter from <a href="http://www.mysqlperformanceblog.com/2008/03/17/researching-your-mysql-table-sizes/" target="_blank">MySQLPerformanceBlog.com</a></p>
<p>In this first example, I was able to see which Storage Engines where using the most disk space, the number of tables, etc:</p>
<blockquote>
<ol>
<li>mysql&gt; SELECT engine,</li>
<li>-&gt; count(*) TABLES,</li>
<li>-&gt; concat(round(sum(table_rows)/1000000,2),&#8217;M') rows,</li>
<li>-&gt; concat(round(sum(data_length)/(1024*1024*1024),2),&#8217;G') DATA,</li>
<li>-&gt; concat(round(sum(index_length)/(1024*1024*1024),2),&#8217;G') idx,</li>
<li>-&gt; concat(round(sum(data_length+index_length)/(1024*1024*1024),2),&#8217;G') total_size,</li>
<li>-&gt; round(sum(index_length)/sum(data_length),2) idxfrac</li>
<li>-&gt; FROM information_schema.TABLES</li>
<li>-&gt; GROUP BY engine</li>
<li>-&gt; ORDER BY sum(data_length+index_length) DESC LIMIT 10;</li>
<li>+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
| engine     | TABLES | rows    | DATA    | idx    | total_size | idxfrac |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
| MyISAM     |   1243 | 941.06M | 244.09G | 4.37G  | 248.47G    |    0.02 |<br />
| InnoDB     |    280 | 682.82M | 63.91G  | 32.49G | 96.40G     |    0.51 |<br />
| MRG_MyISAM |      1 | 13.66M  | 6.01G   | 0.00G  | 6.01G      |    0.00 |<br />
| MEMORY     |     14 | 0.00M   | 0.00G   | 0.00G  | 0.00G      |    NULL |<br />
+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
4 rows IN SET (14.02 sec)</li>
</ol>
</blockquote>
<p>In this next example, I&#8217;m able to see which databases are consuming the most:</p>
<blockquote>
<ol>
<li>SELECT</li>
<li>-&gt; count(*) TABLES,</li>
<li>-&gt; table_schema,concat(round(sum(table_rows)/1000000,2),&#8217;M') rows,</li>
<li>-&gt; concat(round(sum(data_length)/(1024*1024*1024),2),&#8217;G') DATA,</li>
<li>-&gt; concat(round(sum(index_length)/(1024*1024*1024),2),&#8217;G') idx,</li>
<li>-&gt; concat(round(sum(data_length+index_length)/(1024*1024*1024),2),&#8217;G') total_size,</li>
<li>-&gt; round(sum(index_length)/sum(data_length),2) idxfrac</li>
<li>-&gt; FROM information_schema.TABLES</li>
<li>-&gt; GROUP BY table_schema</li>
<li>-&gt; ORDER BY sum(data_length+index_length) DESC LIMIT 10;</li>
<li>+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
| TABLES | table_schema       | rows  | DATA  | idx   | total_size | idxfrac |<br />
+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
|     48 | cacti              | 0.01M | 0.00G | 0.00G | 0.00G      |    0.72 |<br />
|     17 | mysql              | 0.00M | 0.00G | 0.00G | 0.00G      |    0.18 |<br />
|      4 | pdns               | 0.00M | 0.00G | 0.00G | 0.00G      |    1.00 |<br />
|      2 | test               | 0.00M | 0.00G | 0.00G | 0.00G      |    0.12 |<br />
|     16 | information_schema | NULL  | 0.00G | 0.00G | 0.00G      |    NULL |<br />
+&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;+<br />
5 rows IN SET (0.32 sec)</li>
</ol>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2009/01/05/useful-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful tricks with linux date</title>
		<link>http://www.sysadminvalley.com/2008/12/16/useful-tricks-with-linux-date/</link>
		<comments>http://www.sysadminvalley.com/2008/12/16/useful-tricks-with-linux-date/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 23:55:31 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=32</guid>
		<description><![CDATA[Have you ever spent countless time writing a shell script trying to say you want all &#8220;data&#8221; between this date and that date. I&#8217;ve had numerous scripts like this.  Well, recently I got tired of doing this so I re-read the man page for &#8220;date&#8221; and came across this helpful time. Normally when I use [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever spent countless time writing a shell script trying to say you want all &#8220;data&#8221; between this date and that date. I&#8217;ve had numerous scripts like this.  Well, recently I got tired of doing this so I re-read the man page for &#8220;date&#8221; and came across this helpful time.</p>
<p>Normally when I use date I format it how I like, such as 2008-12-16.  To do this I could do</p>
<blockquote><p>date +%Y-%m-%d</p></blockquote>
<p>Or to do 12-16-2008</p>
<blockquote><p>date +%m-%d-%Y</p></blockquote>
<p>But here is the real gem.  I needed to find out what date it was 6 months ago, so this is what I did.</p>
<blockquote><p>date +%Y-%m-%d &#8211;date=&#8217;6 months ago&#8217;</p></blockquote>
<p>And it gave me the correct date of 2008-06-16</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2008/12/16/useful-tricks-with-linux-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backing up a mysql database</title>
		<link>http://www.sysadminvalley.com/2008/12/12/backing-up-a-mysql-database/</link>
		<comments>http://www.sysadminvalley.com/2008/12/12/backing-up-a-mysql-database/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 20:24:57 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mini how-to]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=29</guid>
		<description><![CDATA[I had the need to do a backup and compress a mysql database, so this is how I did it. mysqldump --opt databasename -uUsername -p &#124; gzip &#62; databasename.sql.gz]]></description>
			<content:encoded><![CDATA[<p>I had the need to do a backup and compress a mysql database, so this is how I did it.</p>
<blockquote><p><code>mysqldump --opt databasename -uUsername -p | gzip &gt; databasename.sql.gz</code></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2008/12/12/backing-up-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
