<?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>Blog dot Melimato dot Com &#187; bash</title>
	<atom:link href="http://blog.melimato.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.melimato.com</link>
	<description>Those things we do</description>
	<lastBuildDate>Thu, 24 Dec 2009 11:58:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Restore / uncompress a plesk backup file using terminal</title>
		<link>http://blog.melimato.com/restore-uncompress-a-plesk-backup-file-using-terminal/</link>
		<comments>http://blog.melimato.com/restore-uncompress-a-plesk-backup-file-using-terminal/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 16:51:00 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[Plesk]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[compress]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[mpack]]></category>
		<category><![CDATA[restore]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=190</guid>
		<description><![CDATA[Today I was had to move a few web sites from one server to another. As I did not have ssh or ftp access to it, the only way to do it was through Plesk. As I don&#8217;t have experience using Plesk, I did not know that Plesk&#8217;s built in File Explorer can only be [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was had to move a few web sites from one server to another. As I did not have ssh or ftp access to it, the only way to do it was through <a href="http://www.parallels.com/es/products/plesk/">Plesk</a>. As I don&#8217;t have experience using Plesk, I did not know that Plesk&#8217;s built in File Explorer can only be used to manage your web site&#8217;s files within the server, but it does not let you download those files. So, looking around Plesk&#8217;s admin interface I found the backup feature. That looked promissing, so I clicked on it and it brought me to another page called &#8220;Backup Manager&#8221;. This page allows you to set up periodic or one time backups. Backups can be saved in Plesk&#8217;s local repository or in an external FTP server. So I set up all the FTP details and start the backup. Once the backup finished I tried to open it on a linux box and file-roller gave an error when it tried to extract it. A `file` showed that the file was indeed in gzip format.</p>
<p><span id="more-190"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">file</span> mydomain.com_2009.11.02_13.07
mydomain.com_2009.11.02_13.07: <span style="color: #c20cb9; font-weight: bold;">gzip</span> compressed data, from Unix, <span style="color: #c20cb9; font-weight: bold;">last</span> modified: Mon Nov  <span style="color: #000000;">2</span> <span style="color: #000000;">13</span>:08:<span style="color: #000000;">11</span> <span style="color: #000000;">2009</span></pre></div></div>

<p>Being a gzip file I obviously tried to gunzip it, but again no luck</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">gunzip</span> mydomain.com_2009.11.02_13.07
<span style="color: #c20cb9; font-weight: bold;">gunzip</span> mydomain.com_2009.11.02_13.07
<span style="color: #c20cb9; font-weight: bold;">gzip</span>: mydomain.com_2009.11.02_13.07: unknown suffix <span style="color: #660033;">--</span> ignored</pre></div></div>

<p>After googling around for a quite a while I did not find out what this &#8220;unknown suffix&#8221; error meant, but instead I found on the <a href="http://kb.parallels.com/en/1757">Parallels Knowledge Base</a> how to do it. I&#8217;m copying/pasting it below for future reference:</p>
<blockquote><p>
II. SECOND WAY:</p>
<p>It can be done using mpack tools to work with MIME files. This packet is included into Debian:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># apt-get install mpack</span></pre></div></div>

<p>For other Linux systems you can try to use RPM from ALT Linux:<br />
ftp://ftp.pbone.net/mirror/ftp.altlinux.ru/pub/distributions/ALTLinux/Sisyphus/files/i586/RPMS/mpack-1.6-alt1.i586.rpm<br />
or compile mpack from the sources: http://ftp.andrew.cmu.edu/pub/mpack/.<br />
 &#8211; Create an empty directory to extract the back up file:<br />
# mkdir recover<br />
# cd recover</p>
<p>and copy backup into it. By default Plesk backup is gzipped (if not, use cat), so run zcat to pass data to munpack to extract content  of directories from the backup file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># zcat DUMP_FILE.gz &gt; DUMP_FILE </span>
<span style="color: #666666; font-style: italic;"># cat DUMP_FILE | munpack</span></pre></div></div>

<p> In result you get the set of tar and sql files that contain domains&#8217; directories and databases. Untar the needed directory. For example if you need to restore the httpdocs folder for the DOMAIN.TLD domain:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># tar xvf DOMAIN.TLD.htdocs</span></pre></div></div>

</blockquote>
<p>That did it, after untaring the htdocs file I finnaly got what I wanted. Hope that saves someone some time.</p>
<div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/restore-uncompress-a-plesk-backup-file-using-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash Script to create a new symfony project and install optional plugins</title>
		<link>http://blog.melimato.com/bash-script-to-create-a-new-symfony-project-and-install-optional-plugins/</link>
		<comments>http://blog.melimato.com/bash-script-to-create-a-new-symfony-project-and-install-optional-plugins/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 12:14:07 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=181</guid>
		<description><![CDATA[As we already mentioned in my last post, I have been playing a lot with Symfony these last few months. While I really enjoy working with symfony, it is always a pain to remember how to start a new project, install all the plugins and read the plugin&#8217;s documentation. After googling around I found that [...]]]></description>
			<content:encoded><![CDATA[<p>As we already mentioned in my last post, I have been playing a lot with <a href="http://www.symfony-project.org">Symfony</a> these last few months. While I really enjoy working with symfony, it is always a pain to remember how to start a new project, install all the plugins and read the plugin&#8217;s documentation. After googling around I found that Gordon Franke published <a title="Bash script to build symfony project with sfDoctrinePlugin, sfDoctrineGuardPlugin and sfDoctrineGuardExtraPlugin" href="http://blog.nevalon.de/en/bash-skript-zum-erstelle-eines-symfony-projekts-mit-sfdoctrineplugin-sfdoctrineguardplugin-und-sfdoctrineguardextrapluginbash-script-to-build-symfony-project-with-sfdoctrineplugin-sfdoctrineguardplu-20090324">this</a> post. It had a basic script to install symfony and have it working out of the box with very little effort. Me, being a huge fan of little effort, decided to change this script so that it&#8217;s even more useful and more powerful, so I don&#8217;t loose time installing all those boring and needed plugins I like. The result can be found on <a title="Symfony and plugins installation script" href="http://github.com/melimato/symfony-and-plugins-installation-script">GitHub</a>. The script works pretty well, but it does have bugs, so don&#8217;t be shy and report them, or fix them when you find one!</p>
<div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/bash-script-to-create-a-new-symfony-project-and-install-optional-plugins/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Get unix timestamp in bash</title>
		<link>http://blog.melimato.com/get-unix-timestamp-in-bash/</link>
		<comments>http://blog.melimato.com/get-unix-timestamp-in-bash/#comments</comments>
		<pubDate>Sat, 09 May 2009 16:04:03 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[date/time]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=108</guid>
		<description><![CDATA[I&#8217;m posting this since I always forget it&#8230; date +%s More info: http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/ Readers who viewed this page, also viewed:Powered by Where did they go from here?]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m posting this since I always forget it&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>s</pre></div></div>

<p>More info: <a href="http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/">http://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/</a></p>
<div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/get-unix-timestamp-in-bash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Keeping directories in sync with unison</title>
		<link>http://blog.melimato.com/keeping-directories-in-sync-with-unison/</link>
		<comments>http://blog.melimato.com/keeping-directories-in-sync-with-unison/#comments</comments>
		<pubDate>Fri, 08 May 2009 23:24:09 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[unison]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=104</guid>
		<description><![CDATA[As opposed to rsync, unison is a two way file synchronizer. Similar to MySQL&#8217;s master to master replication. To set it up in Ubuntu (Intrepid) keep on reading&#8230; 1. Install unison on both servers apt-get install unison 2. Create a script to add to crontab to call unison periodically unison -numericids -owner -silent -times -contactquietly [...]]]></description>
			<content:encoded><![CDATA[<p>As opposed to rsync, unison is a two way file synchronizer. Similar to MySQL&#8217;s master to master replication. To set it up in Ubuntu (Intrepid) keep on reading&#8230;</p>
<p><span id="more-104"></span></p>
<p>1. Install unison on both servers</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> unison</pre></div></div>

<p>2. Create a script to add to crontab to call unison periodically</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">unison <span style="color: #660033;">-numericids</span> <span style="color: #660033;">-owner</span> <span style="color: #660033;">-silent</span> <span style="color: #660033;">-times</span> <span style="color: #660033;">-contactquietly</span> <span style="color: #660033;">-batch</span> <span style="color: #660033;">-auto</span> <span style="color: #660033;">-log</span> <span style="color: #660033;">-logfile</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>unison.log profile_file <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

<p>3. Create the above mentioned profile file on ~/.unison/profile_file.prf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root = <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>server_ip<span style="color: #000000; font-weight: bold;">//</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span>
root = <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span>
ignore = Regex .<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>cache<span style="color: #000000; font-weight: bold;">|</span>Cache<span style="color: #000000; font-weight: bold;">|</span>te?mp<span style="color: #000000; font-weight: bold;">|</span>logs?<span style="color: #7a0874; font-weight: bold;">&#41;</span>.<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #666666; font-style: italic;"># ignore log and cache files</span></pre></div></div>

<p>That&#8217;s it! Now add the following line to your crontab to execute it every 5min</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my_unison_script.sh</pre></div></div>

<p>After a few days of running this I found that sometimes one unison execution would overlap another. To resolve this I found a little tool called <a href="http://unixwiz.net/tools/lockrun.html">lockrun</a></p>
<p>To get it to work I did:</p>
<p>1. Download the source code from the official <a href="http://unixwiz.net/tools/lockrun.c">lockrun website</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>unixwiz.net<span style="color: #000000; font-weight: bold;">/</span>tools<span style="color: #000000; font-weight: bold;">/</span>lockrun.c</pre></div></div>

<p>2. Build/install as shown in <a href="http://unixwiz.net/tools/lockrun.html">http://unixwiz.net/tools/lockrun.html</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gcc</span> lockrun.c <span style="color: #660033;">-o</span> lockrun
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> lockrun <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>3. Change the previous crontab line to use lockrun</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>lockrun <span style="color: #660033;">--lockfile</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>hosting.lockrun <span style="color: #660033;">--</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my_unison_script.sh</pre></div></div>

<p>All done!!!</p>
<div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/keeping-directories-in-sync-with-unison/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Make svnserve load on startup (Ubuntu)</title>
		<link>http://blog.melimato.com/make-svnserve-load-on-startup-ubuntu/</link>
		<comments>http://blog.melimato.com/make-svnserve-load-on-startup-ubuntu/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 15:23:14 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[svn]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=96</guid>
		<description><![CDATA[Make svnserve load on startup: First create a new script on init.d vi /etc/init.d/svnserve The script&#8217;s contents: #!/bin/bash ### BEGIN INIT INFO # Provides: svnserve # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start subversion server ### END [...]]]></description>
			<content:encoded><![CDATA[<p>Make svnserve load on startup:</p>
<p>First create a new script on init.d</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">svnserve</span></pre></div></div>

<p><span id="more-96"></span></p>
<p>The script&#8217;s contents:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #666666; font-style: italic;"># Provides:          svnserve</span>
<span style="color: #666666; font-style: italic;"># Required-Start:    $local_fs $remote_fs $network $syslog</span>
<span style="color: #666666; font-style: italic;"># Required-Stop:     $local_fs $remote_fs $network $syslog</span>
<span style="color: #666666; font-style: italic;"># Default-Start:     2 3 4 5</span>
<span style="color: #666666; font-style: italic;"># Default-Stop:      0 1 6</span>
<span style="color: #666666; font-style: italic;"># Short-Description: Start subversion server</span>
<span style="color: #666666; font-style: italic;">### END INIT INFO</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">svnserve</span> <span style="color: #660033;">--listen-host</span>=myhost.com <span style="color: #660033;">-d</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>repos</pre></div></div>

<p>Then make the script is executable</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">svnserve</span></pre></div></div>

<p>Use update-rc.d to add script to init</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">update-rc.d <span style="color: #c20cb9; font-weight: bold;">svnserve</span> defaults</pre></div></div>

<p>That&#8217;s it!</p>
<div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://blog.melimato.com/set-new-logrotate-tasks-to-rotate-apache-logs-in-non-standard-directories/" rel="bookmark" class="wherego_title">Set new logrotate tasks to rotate apache logs in non-standard directories</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/make-svnserve-load-on-startup-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Set new logrotate tasks to rotate apache logs in non-standard directories</title>
		<link>http://blog.melimato.com/set-new-logrotate-tasks-to-rotate-apache-logs-in-non-standard-directories/</link>
		<comments>http://blog.melimato.com/set-new-logrotate-tasks-to-rotate-apache-logs-in-non-standard-directories/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 15:52:36 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[logrotate]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[log]]></category>

		<guid isPermaLink="false">http://www.melimato.com/blog/?p=64</guid>
		<description><![CDATA[I prefer compressing old logs to save space. Edit logrotate.conf vi /etc/logrotate.conf Uncomment the following line: compress Since I keep all my hosting&#8217;s logs in /home/hosting/log I need to add a new task to logrotate: Create a new file under logrotate.d called hosting: vi /etc/logrotate.d/hosting Add the following contents to that file: /home/hosting/*/log/*.log &#123; weekly [...]]]></description>
			<content:encoded><![CDATA[<p>I prefer compressing old logs to save space. Edit logrotate.conf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>logrotate.conf</pre></div></div>

<p><span id="more-64"></span></p>
<p>Uncomment the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">compress</pre></div></div>

<p>Since I keep all my hosting&#8217;s logs in /home/hosting/log I need to add a new task to logrotate:</p>
<p>Create a new file under logrotate.d called hosting:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>logrotate.d<span style="color: #000000; font-weight: bold;">/</span>hosting</pre></div></div>

<p>Add the following contents to that file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>hosting<span style="color: #000000; font-weight: bold;">/*/</span>log<span style="color: #000000; font-weight: bold;">/*</span>.log <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  weekly
    missingok
    rotate <span style="color: #000000;">52</span>
    compress
    delaycompress
    notifempty
    create <span style="color: #000000;">640</span> root adm
    sharedscripts
    postrotate
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #780078;">`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 reload <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        <span style="color: #000000; font-weight: bold;">fi</span>
    endscript
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Explanation of script lines according to man page:</p>
<p><strong>missingok</strong><br />
If the log file is missing, go on to the next one without issuing an error message.</p>
<p><strong>rotate</strong> <em>count</em><br />
Log files are rotated <count> times before being removed or mailed to the address specified in a mail directive. If count is 0, old versions are removed rather then rotated.<br />
In our case we will remove logfiles older than 1 year (52 weeks)</p>
<p><strong>compress</strong><br />
Duh!</p>
<p><strong>delaycompress</strong><br />
Postpone compression of the previous log file to the next rotation cycle. This has only effect when used in combination with compress. It can be used when some program can not be told to close its logfile and thus might continue writing to the previous log file for some time.</p>
<p><strong>notifempty</strong><br />
Do not rotate the log if it is empty (this overrides the ifempty option).</p>
<p><strong>create</strong> <em>mode owner group</em><br />
Immediately after rotation (before the postrotate script is run) the log file is created (with the same name as the log file just rotated).  mode specifies the mode for the log file in octal (the same as chmod(2)), owner specifies the user name who will own the log file, and group specifies the group the log file will belong to. Any of the log file attributes may be omitted, in which case those attributes for the new file will use the same values as the original log file for the omitted attributes. This option can be disabled using the nocreate option.</p>
<p><strong>sharedscripts</strong><br />
Normally, <strong>prescript</strong> and <strong>postscript</strong> scripts are run for each log which is rotated, meaning that a single script may be run multiple times for log file entries which match multiple files (such as the /var/log/news/* example). If <strong>sharedscript</strong> is specified, the scripts are only run once, no matter how many logs match the wildcarded pattern. However, if none of the logs in the pattern require rotating, the scripts will not be run at all. This option overrides the nosharedscripts option and implies <strong>create</strong> option.<br />
<strong>postrotate/endscript</strong><br />
The lines between postrotate and endscript (both of which must appear on lines by themselves) are executed after the log file is rotated. These directives may only appear inside of a log file definition.</p>
<div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://blog.melimato.com/svn-setup-and-migration/" rel="bookmark" class="wherego_title">svn setup and migration</a></li><li><a href="http://blog.melimato.com/make-svnserve-load-on-startup-ubuntu/" rel="bookmark" class="wherego_title">Make svnserve load on startup (Ubuntu)</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/set-new-logrotate-tasks-to-rotate-apache-logs-in-non-standard-directories/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to exchange ssh keys for passwordless login</title>
		<link>http://blog.melimato.com/how-to-exchange-ssh-keys-for-passwordless-login/</link>
		<comments>http://blog.melimato.com/how-to-exchange-ssh-keys-for-passwordless-login/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 14:55:56 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.melimato.com/blog/?p=3</guid>
		<description><![CDATA[As I&#8217;m always using ssh, copying or rsyncing files between all my servers I find it very annoying to always have to type in my login password. To avoid that, I exchanged my ssh keys so that all the authentication is done through those keys. To achieve that simply: On the machine you want to [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;m always using ssh, copying or rsyncing files between all my servers I find it very annoying to always have to type in my login password. To avoid that, I exchanged my ssh keys so that all the authentication is done through those keys. To achieve that simply:</p>
<p><span id="more-3"></span></p>
<p>On the machine you want to have access from:</p>
<p>1. Generate a new key if you don&#8217;t already have one:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span></pre></div></div>

<p>2. Copy the key accross to the other server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa.pub <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>target_machine <span style="color: #c20cb9; font-weight: bold;">cat</span> - <span style="color: #ff0000;">&quot;&gt;&gt;&quot;</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>Now when you want to ssh or scp or rsync user@target_machine you won&#8217;t need to use a password any more!</p>
<div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/how-to-exchange-ssh-keys-for-passwordless-login/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to sync date/time in Ubuntu Intrepid</title>
		<link>http://blog.melimato.com/how-to-sync-datetime-in-ubuntu-intrepid/</link>
		<comments>http://blog.melimato.com/how-to-sync-datetime-in-ubuntu-intrepid/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 14:55:39 +0000</pubDate>
		<dc:creator>pablo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[chrony]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ntp]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.melimato.com/blog/?p=9</guid>
		<description><![CDATA[In order to keep my servers always showing the correct date/time I use a little software called chrony and make sure I&#8217;m using the correct time zone. All the actions below need superuser privileges To install it simply use apt-get: $ apt-get install chrony Once you&#8217;ve installed chrony you need to select your current time [...]]]></description>
			<content:encoded><![CDATA[<p>In order to keep my servers always showing the correct date/time I use a little software called <a href="http://chrony.sunsite.dk/" title="chrony website">chrony</a> and make sure I&#8217;m using the correct time zone.</p>
<p><span id="more-9"></span></p>
<p><strong>All the actions below need superuser privileges</strong></p>
<p>To install it simply use apt-get:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> chrony</pre></div></div>

<p>Once you&#8217;ve installed chrony you need to select your current time zone:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ tzselect</pre></div></div>

<p>To make sure it is selected on every boot I just export the TZ environment variable in my /etc/rc.local</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.local</pre></div></div>

<p>And add the following lines:<br />
# Export timezone<br />
TZ=&#8217;Europe/Brussels&#8217;; export TZ</p>
<p>I found doing the above was not enough, so I also edited my /etc/timezone file and added the correct time zone there:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Europe/Brussels&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>timezone</pre></div></div>

<p>And still it wasn&#8217;t enough, so I reconfigured the package tzdata</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ dpkg-reconfigure tzdata</pre></div></div>

<p>And finally that did it! To make sure it would still be correct on a future reboot I rebooted my machine:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ reboot</pre></div></div>

<div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/how-to-sync-datetime-in-ubuntu-intrepid/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
