<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Globalways Blog - Linux</title>
    <link>http://www.globalways.net/blog/</link>
    <description></description>
    <dc:language>de</dc:language>
    <generator>Serendipity 1.1.3 - http://www.s9y.org/</generator>
    <pubDate>Wed, 25 Aug 2010 07:48:01 GMT</pubDate>

    <image>
        <url>http://www.globalways.net/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Globalways Blog - Linux - </title>
        <link>http://www.globalways.net/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Strace with multiple processes</title>
    <link>http://www.globalways.net/blog/archives/52-Strace-with-multiple-processes.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/52-Strace-with-multiple-processes.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=52</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=52</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    Usually, you trace a single process that does not give a helpful error message. But if you have to trace e.g. a webserver with multiple processes you have to type a lot. Here is a one-liner that makes it a little bit easier:
&lt;pre&gt;
strace -f -p $(ps -ea f| grep &lt;span style=&quot;color: red&quot;&gt;httpsd&lt;/span&gt; | cut -f 1 -d &quot; &quot; | xargs | sed -e &#039;s/ / -p /g&#039;) 1&gt;/tmp/strace.log 2&gt;&amp;1
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Wed, 25 Aug 2010 09:48:01 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/52-guid.html</guid>
    
</item>
<item>
    <title>Dumping json-data in shell</title>
    <link>http://www.globalways.net/blog/archives/51-Dumping-json-data-in-shell.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/51-Dumping-json-data-in-shell.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=51</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=51</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    &lt;p&gt;When using web services, its sometimes hard to read the serialized json data. I wrote a small helper script to dump the contents&lt;/p&gt;

&lt;p&gt;File: /usr/local/bin/json_decode&lt;/p&gt;
&lt;pre&gt;
#!/usr/bin/php
&amp;lt;?php
error_reporting(E_ALL);
ini_set(&#039;display_errors&#039;,true);
if(!empty($argv[1])) {
        $json = file_get_contents($argv[1]);
}
else {
        $json = &#039;&#039;;
        while(!feof(STDIN)) {
                $json .= fgets(STDIN, 1024);
        }
}

$data = json_decode($json);

if($data === null) {
        fwrite(STDERR, &quot;Invalid json data\n&quot;);
        exit(1);
}

print_r($data);
&lt;/pre&gt;

&lt;p&gt;Usage:&lt;/p&gt;
&lt;pre&gt;
wget --quiet -O - &quot;http://domain.tld/file.json&quot; | json_decode
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Thu, 17 Jun 2010 15:58:09 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/51-guid.html</guid>
    
</item>
<item>
    <title>Find symbolic links</title>
    <link>http://www.globalways.net/blog/archives/49-Find-symbolic-links.html</link>
            <category>Linux</category>
    
    <comments>http://www.globalways.net/blog/archives/49-Find-symbolic-links.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=49</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=49</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    &lt;pre&gt;
find -lname &quot;*&quot; | xargs ls -l
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Thu, 12 Nov 2009 16:59:22 +0100</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/49-guid.html</guid>
    
</item>
<item>
    <title>Flushing swap space</title>
    <link>http://www.globalways.net/blog/archives/40-Flushing-swap-space.html</link>
            <category>Linux</category>
    
    <comments>http://www.globalways.net/blog/archives/40-Flushing-swap-space.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=40</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=40</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    &lt;p&gt;From time to time machines use some swap space due to heavy load. But Linux doesn&#039;t free the swap space itself if enough memory is available.&lt;/p&gt;

&lt;p&gt;An easy method to flush all disk swap to memory is to disable and re-enable the swap. Eg:&lt;/p&gt;

&lt;pre&gt;
# free -tm
             total       used       free     shared    buffers     cached
Mem:          4096       3269        826          0         31         76
-/+ buffers/cache:       3161        934
Swap:          509        114        395
Total:        4605       3384       1221

# swapoff /dev/xvdb1
# swapon /dev/xvdb1

# free -tm
             total       used       free     shared    buffers     cached
Mem:          4096       3375        720          0         31         78
-/+ buffers/cache:       3265        830
Swap:          509          0        509
Total:        4605       3375       1230

&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Thu, 16 Jul 2009 13:31:12 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/40-guid.html</guid>
    
</item>
<item>
    <title>Uptime-Devil</title>
    <link>http://www.globalways.net/blog/archives/35-Uptime-Devil.html</link>
            <category>Linux</category>
    
    <comments>http://www.globalways.net/blog/archives/35-Uptime-Devil.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=35</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=35</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    
&lt;pre&gt;18:23:51 up 666 days,  2:55,  1 user,  load average: 0.01, 0.02, 0.00&lt;/pre&gt;
 
    </content:encoded>

    <pubDate>Wed, 17 Jun 2009 18:24:24 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/35-guid.html</guid>
    
</item>
<item>
    <title>for-loop in bash</title>
    <link>http://www.globalways.net/blog/archives/30-for-loop-in-bash.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/30-for-loop-in-bash.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=30</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=30</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    
&lt;p&gt;If you want to update several hosts at once you can use a for-loop in a shell to execute a command on serveral hosts&lt;/p&gt;
&lt;pre&gt;for i in 1  3 `seq 4 7` 9; do HOST=&amp;quot;1.2.3.$i&amp;quot;; ssh root@$HOST &lt;command&gt;; done;
&lt;/command&gt;&lt;/pre&gt;
&lt;p&gt;As you can see it is very easy to create a custom set of items to loop through. On the one hand you can use any value seperated by a space or you can create a sequence of numbers with the seq-command.&lt;/p&gt; 
    </content:encoded>

    <pubDate>Wed, 06 Aug 2008 14:45:30 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/30-guid.html</guid>
    
</item>
<item>
    <title>Locales support</title>
    <link>http://www.globalways.net/blog/archives/21-Locales-support.html</link>
            <category>Linux</category>
    
    <comments>http://www.globalways.net/blog/archives/21-Locales-support.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=21</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=21</wfw:commentRss>
    

    <author>nospam@example.com (Uli Stärk)</author>
    <content:encoded>
    
&lt;p&gt;I tried setting up a new blog that should display german date format, but none of the (usually valid) locales worked. The php function setlocale() always returned false. So I searched and found a debian package that fixed my problem, by installing all locales:&lt;/p&gt;&lt;pre&gt;apt-get install locales-all&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Fri, 23 Nov 2007 12:52:28 +0100</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/21-guid.html</guid>
    
</item>
<item>
    <title>Setting up a MoinMoinWiki</title>
    <link>http://www.globalways.net/blog/archives/14-Setting-up-a-MoinMoinWiki.html</link>
            <category>Linux</category>
    
    <comments>http://www.globalways.net/blog/archives/14-Setting-up-a-MoinMoinWiki.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=14</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=14</wfw:commentRss>
    

    <author>nospam@example.com (globalways Admin)</author>
    <content:encoded>
    
As the MediaWiki is not my favorite choice, when installing an wiki - &lt;a href=&quot;http://moinmoin.wikiwikiweb.de&quot; target=&quot;_blank&quot;&gt;MoinMoinWiki&lt;/a&gt; is currently my first choice, because it offers some kind of Page-Hierarchy to create a simple structure in your wiki articles.

Installing and configuring the wiki is quite easy on a debian system. &lt;br /&gt;&lt;a href=&quot;http://www.globalways.net/blog/archives/14-Setting-up-a-MoinMoinWiki.html#extended&quot;&gt;&quot;Setting up a MoinMoinWiki&quot; vollständig lesen&lt;/a&gt;
    </content:encoded>

    <pubDate>Sat, 08 Sep 2007 17:45:03 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/14-guid.html</guid>
    
</item>
<item>
    <title>Removing files and free disk space</title>
    <link>http://www.globalways.net/blog/archives/12-Removing-files-and-free-disk-space.html</link>
            <category>Linux</category>
    
    <comments>http://www.globalways.net/blog/archives/12-Removing-files-and-free-disk-space.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=12</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=12</wfw:commentRss>
    

    <author>nospam@example.com (globalways Admin)</author>
    <content:encoded>
    
Today I noticed, that the free disk space on one of our servers went low. A quick look pointed to a very large mysqld.err logfile.
&lt;pre&gt;
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              45G   41G  4.4G  91% /
# cd /var/log/mysql
# ls -al
total 27062512
drwxr-x--- 2 mysql mysql          82 Jul 17 00:05 .
drwxr-xr-x 9 root  root         4096 Aug 29 19:32 ..
-rw-r--r-- 1 mysql mysql           0 Jul 17 00:05 .keep_dev-db_mysql-0
-rw-rw---- 1 mysql mysql           0 Jul 17 00:06 mysql.err
-rw-rw---- 1 mysql mysql           0 Jul 17 00:06 mysql.log
-rw-rw---- 1 mysql mysql 27712011858 Sep  7 15:32 mysqld.err

&lt;/pre&gt;

So after resolving the spamming issue I removed the error logfile.
&lt;pre&gt;
# rm mysqld.err
# /etc/init.d/syslog-ng restart
 \* Stopping syslog-ng ... [ ok ]
 \* Starting syslog-ng ...  [ ok ]
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              45G   41G  4.4G  91% /
udev                  512M   24K  512M   1% /dev
&lt;/pre&gt;

Huh? No effect on the free disk space? The problem is, that mysqld had still an open filehandle on the error logfile. So the filesystem didn&#039;t free the disk space. Restarting mysqld resolved this issue.

&lt;pre&gt;
# /etc/init.d/mysql restart
 \* Stopping mysql ... [ ok ]
 \* Stopping mysqld (0)  [ ok ]
 \* Starting mysql ...
 \* Starting mysql (/etc/mysql/my.cnf)  [ ok ]

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              45G   15G   31G  33% /
udev                  512M   24K  512M   1% /dev
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Fri, 07 Sep 2007 15:53:52 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/12-guid.html</guid>
    
</item>
<item>
    <title>Bash: Arithmetic operations using bash</title>
    <link>http://www.globalways.net/blog/archives/2-Bash-Arithmetic-operations-using-bash.html</link>
            <category>Scripting (Bash/Perl)</category>
    
    <comments>http://www.globalways.net/blog/archives/2-Bash-Arithmetic-operations-using-bash.html#comments</comments>
    <wfw:comment>http://www.globalways.net/blog/wfwcomment.php?cid=2</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://www.globalways.net/blog/rss.php?version=2.0&amp;type=comments&amp;cid=2</wfw:commentRss>
    

    <author>nospam@example.com (Markus Binder)</author>
    <content:encoded>
    
When using the bash shell sometimes you need arithmetic calculations (like plus, minus, multiply, divide) on variables and numbers.

&lt;strong&gt;Simple division by 5&lt;/strong&gt;

&lt;pre&gt;
i=10
echo $[$i/5];
2
&lt;/pre&gt;

&lt;strong&gt;Better use-case: do 10 times the same command&lt;/strong&gt;

&lt;pre&gt;
host ~ # i=0; while [ $i -lt 10 ]; do echo $i; i=$[$i+1]; done
0
1
2
3
4
5
6
7
8
9
&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Wed, 25 Jul 2007 12:06:17 +0200</pubDate>
    <guid isPermaLink="false">http://www.globalways.net/blog/archives/2-guid.html</guid>
    
</item>

</channel>
</rss>