<?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>Jetpack Flight Log &#187; linux</title>
	<atom:link href="http://jetpackweb.com/blog/tags/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://jetpackweb.com/blog</link>
	<description>Rock{et}ing the interweb</description>
	<lastBuildDate>Wed, 19 May 2010 22:21:53 +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>Useful Linux Trick: cron  @reboot</title>
		<link>http://jetpackweb.com/blog/2009/07/17/useful-linux-trick-cron-reboot/</link>
		<comments>http://jetpackweb.com/blog/2009/07/17/useful-linux-trick-cron-reboot/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 17:19:03 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[cron]]></category>

		<guid isPermaLink="false">http://jetpackweb.com/blog/?p=138</guid>
		<description><![CDATA[There are various ways to make sure something is run at system startup &#8211; Redhat has /etc/rc.local script, and it and many others have /etc/init.d/* scripts &#8211; but many times you might not have access to those files or creating init scripts might be overkill for your needs. People are always amazed when I tell [...]]]></description>
			<content:encoded><![CDATA[<p>There are various ways to make sure something is run at system startup &#8211; Redhat has <strong>/etc/rc.local</strong> script, and it and many others have <strong>/etc/init.d/*</strong> scripts &#8211; but many times you might not have access to those files or creating init scripts might be overkill for your needs.</p>
<p>People are always amazed when I tell them they can achieve this basic functionality by using cron. Many of our websites use <a href="http://sphinxsearch.com/" target="_blank">Sphinx</a>, the excellent full text indexer, to allow site searches. Should the server ever reboot, we need to make multiple search daemons start back up. Take the following line from a crontab:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;">crontab <span class="re5">-l</span>
&nbsp;
<span class="sy0">@</span>reboot <span class="sy0">/</span>usr<span class="sy0">/</span>local<span class="sy0">/</span>bin<span class="sy0">/</span>searchd <span class="re5">--config</span> ~<span class="sy0">/</span>conf<span class="sy0">/</span>sphinx.conf</pre></div></div>

<p>This will make sure the <i>searchd</i> daemon starts on bootup.</p>
<p>Also there are a few other shortcuts you can use:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;"><span class="sy0">@</span>yearly        Run once a year, <span class="st0">&quot;0 0 1 1 *&quot;</span>.
<span class="sy0">@</span>annually      <span class="br0">&#40;</span>same <span class="kw2">as</span> <span class="sy0">@</span>yearly<span class="br0">&#41;</span>
<span class="sy0">@</span>monthly       Run once a month, <span class="st0">&quot;0 0 1 * *&quot;</span>.
<span class="sy0">@</span>weekly        Run once a week, <span class="st0">&quot;0 0 * * 0&quot;</span>.
<span class="sy0">@</span>daily         Run once a day, <span class="st0">&quot;0 0 * * *&quot;</span>.
<span class="sy0">@</span>midnight      <span class="br0">&#40;</span>same <span class="kw2">as</span> <span class="sy0">@</span>daily<span class="br0">&#41;</span>
<span class="sy0">@</span>hourly        Run once an hour, <span class="st0">&quot;0 * * * *&quot;</span>.</pre></div></div>

<p>See <strong>man 5 cron</strong> for more information.</p>
<p>(And to be pedantic, @reboot is run when cron is started or restarted, not necessarily the OS itself. So <strong>/etc/init.d/cron restart</strong> would trigger that line to be run. You may want to keep that in mind.)</p>
]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2009/07/17/useful-linux-trick-cron-reboot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>chkdsk and Grub</title>
		<link>http://jetpackweb.com/blog/2009/07/13/chkdsk-and-grub/</link>
		<comments>http://jetpackweb.com/blog/2009/07/13/chkdsk-and-grub/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 23:41:28 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[chkdsk]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://jetpackweb.com/blog/?p=27</guid>
		<description><![CDATA[Recently I used GParted to resize an NTFS disk to dual boot Ubuntu and Windows XP. I finished the Ubuntu installation and everything seemed to be working fine until I tried to boot back into XP. Windows reported there might be disk corruption, ran chkdsk, and chkdsk ended up freezing. I rebooted again and saw [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I used GParted to resize an NTFS disk to dual boot Ubuntu and Windows XP. I finished the Ubuntu installation and everything seemed to be working fine until I tried to boot back into XP. Windows reported there might be disk corruption, ran chkdsk, and chkdsk ended up freezing. I rebooted again and saw that the grub bootloader was now also freezing. Delightful. Although I didn&#8217;t think chkdsk modified the MBR, upon further research in some cases it does(when run with the /r switch) and in this case ends up corrupting the MBR. To fix this issue you can perform the following:</p>
<p>Boot with an Ubuntu Live CD and open up a terminal.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;"><span class="kw2">sudo</span> grub
&nbsp;
grub<span class="sy0">&gt;</span> <span class="kw2">find</span> <span class="sy0">/</span>boot<span class="sy0">/</span>grub<span class="sy0">/</span>stage1</pre></div></div>

<p>Note the hd<em>x</em> number and partition number to it&#8217;s right. Now type the following commands into the grub prompt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;">grub<span class="sy0">&gt;</span> root <span class="br0">&#40;</span>hdx, y<span class="br0">&#41;</span>
&nbsp;
grub<span class="sy0">&gt;</span> setup <span class="br0">&#40;</span>hdx<span class="br0">&#41;</span>
&nbsp;
grub<span class="sy0">&gt;</span> quit</pre></div></div>

<p>Note whitespace is important here. Now you can reboot. When Windows asks to run chkdsk hit a key to cancel. Once in Windows, open a command prompt and type:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;">chkntfs <span class="sy0">/</span>c c:</pre></div></div>

<p>This will schedule a disk check on reboot that will not alter the MBR. Reboot and allow the disk check to complete. It may automatically reboot your system again, but once that is finished both OS&#8217;s should boot fine from now on.</p>
]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2009/07/13/chkdsk-and-grub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN autobackup restore</title>
		<link>http://jetpackweb.com/blog/2008/11/04/svn-autobackup-restore/</link>
		<comments>http://jetpackweb.com/blog/2008/11/04/svn-autobackup-restore/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 19:02:32 +0000</pubDate>
		<dc:creator>Brian Racer</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.jetpackllc.com/?p=7</guid>
		<description><![CDATA[I have been using Doug Hellman&#8217;s useful svnautobackup script for our subversion backups. I think it is a pretty useful script, but it only focuses on backups and not restoration. During a recent server upgrade I needed to restore a large amount of repositories from our dumpfiles. I made the following shell script in php [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using <a href="http://blog.doughellmann.com/">Doug Hellman&#8217;s</a> useful <a href="http://code.google.com/p/svnautobackup/" target="_blank">svnautobackup</a> script for our subversion backups. I think it is a pretty useful script, but it only focuses on backups and not restoration.</p>
<p>During a recent server upgrade I needed to restore a large amount of repositories from our dumpfiles. I made the following shell script in php that will loop through all of the backup dumps and restore them. There is a <a href="http://blogs.law.harvard.edu/hoanga/2008/07/03/svnbackup-restorerb-svnbackups-handy-companion-tool/" target="_blank">similar tool</a> that uses ruby, but it can only restore one repository and I do not know enough ruby to modify it <img src='http://jetpackweb.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family: Monaco, monospace;">#!/usr/bin/php -q
<span class="kw2">&lt;?php</span> 
<span class="co1">// edit this</span>
<span class="re0">$repo_dir</span> <span class="sy0">=</span> <span class="st_h">'/svn/'</span><span class="sy0">;</span>
<span class="re0">$backup_dir</span> <span class="sy0">=</span> <span class="st_h">'/home/backup/svn/'</span><span class="sy0">;</span>
&nbsp;
<span class="co1">// don't edit this</span>
<span class="kw1">foreach</span><span class="br0">&#40;</span><span class="kw2">new</span> DirectoryIterator<span class="br0">&#40;</span><span class="re0">$backup_dir</span><span class="br0">&#41;</span> <span class="kw1">as</span> <span class="re0">$file</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span> 
  <span class="kw1">if</span><span class="br0">&#40;</span>isDir<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="sy0">!</span><span class="re0">$file</span><span class="sy0">-&gt;</span><span class="me1">isDot</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
  <span class="br0">&#123;</span>
    <span class="co1">// get files</span>
    <span class="re0">$dumpfiles</span> <span class="sy0">=</span> <span class="kw3">glob</span><span class="br0">&#40;</span><span class="re0">$backup_dir</span><span class="sy0">.</span><span class="re0">$file</span><span class="sy0">.</span><span class="st_h">'/dumpfile*.bzip2'</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="co1">// sort them</span>
    <span class="kw3">natsort</span><span class="br0">&#40;</span><span class="re0">$dumpfiles</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="co1">// create the repo if not exists</span>
    <span class="kw1">if</span><span class="br0">&#40;</span><span class="sy0">!</span><span class="kw3">is_dir</span><span class="br0">&#40;</span><span class="re0">$repo_dir</span><span class="sy0">.</span><span class="re0">$file</span><span class="br0">&#41;</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
      <span class="re0">$cmd</span> <span class="sy0">=</span>  <span class="st0">&quot;svnadmin create <span class="es4">{$repo_dir}</span><span class="es4">{$file}</span>&quot;</span><span class="sy0">;</span>
      <span class="kw3">system</span><span class="br0">&#40;</span><span class="kw3">escapeshellcmd</span><span class="br0">&#40;</span><span class="re0">$cmd</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <span class="co1">// restore dump files</span>
    <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$dumpfiles</span> <span class="kw1">as</span> <span class="re0">$dumpfile</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
      <span class="re0">$cmd</span> <span class="sy0">=</span> <span class="st0">&quot;bzcat <span class="es4">{$dumpfile}</span> | svnadmin load <span class="es4">{$repo_dir}</span><span class="es4">{$file}</span>&quot;</span><span class="sy0">;</span>
      <span class="kw3">system</span><span class="br0">&#40;</span><span class="kw3">escapeshellcmd</span><span class="br0">&#40;</span><span class="re0">$cmd</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
  <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div>

<p>For reference, here is the script that runs nightly though cron</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family: Monaco, monospace;"><span class="co0">#!/bin/bash</span>
&nbsp;
<span class="re2">files</span>=<span class="sy0">`</span><span class="kw2">ls</span> <span class="sy0">/</span><span class="kw2">svn</span><span class="sy0">`</span>
<span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> <span class="re1">$files</span>
<span class="kw1">do</span>
  <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re5">-d</span> <span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span> <span class="br0">&#93;</span>
  <span class="kw1">then</span>
    <span class="kw2">mkdir</span> <span class="re5">-p</span> <span class="re1">$file</span>
    <span class="sy0">/</span>home<span class="sy0">/</span>backup<span class="sy0">/</span>scripts<span class="sy0">/</span>svnautobackup<span class="sy0">/</span>svnbackup.sh <span class="re5">-v</span> <span class="re5">-i</span> <span class="nu0">100</span> <span class="re5">--history-file</span> <span class="sy0">/</span>home<span class="sy0">/</span>backup<span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span>-hist <span class="re5">--out-dir</span> <span class="sy0">/</span>home<span class="sy0">/</span>backup<span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span> <span class="sy0">/</span>svn<span class="sy0">/</span><span class="re1">$file</span>
  <span class="kw1">fi</span>
<span class="kw1">done</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://jetpackweb.com/blog/2008/11/04/svn-autobackup-restore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
