<?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>Talk Funnel &#187; mac</title>
	<atom:link href="http://ramin.firoozye.com/tag/mac/feed/" rel="self" type="application/rss+xml" />
	<link>http://ramin.firoozye.com</link>
	<description>Ramin Firoozye&#039;s Public Whisperings</description>
	<lastBuildDate>Fri, 02 Jul 2010 22:19:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Slowing down Time Machine</title>
		<link>http://ramin.firoozye.com/2008/11/08/slowing-down-time-machine/</link>
		<comments>http://ramin.firoozye.com/2008/11/08/slowing-down-time-machine/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 02:35:26 +0000</pubDate>
		<dc:creator>ramin</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[time machine]]></category>

		<guid isPermaLink="false">http://ramin.firoozye.com/?p=64</guid>
		<description><![CDATA[Time Machine is great, especially if hooked up to a network storage device like Drobo so you can just have it run in the background. In my case the Drobo is connected to a Mac Mini acting as a network file server (yes, I know it&#8217;s not officially supported, but it works fine under Leopard). [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://ramin.firoozye.com/i/timemachine.jpg" width="102" height="102" alt="" /></p>
<p>Time Machine is great, especially if hooked up to a network storage device like <a href="http://drobo.com/" target="_blank">Drobo</a> so you can just have it run in the background. In my case the Drobo is connected to a Mac Mini acting as a network file server (yes, I know it&#8217;s not <em>officially</em> supported, but it works fine under Leopard). </p>
<p>However, lately the backups have been taking a lot of system and network resources, rendering the machine (in this case my development laptop) practically unusable while they run. But since Time Machine runs in the background, it&#8217;s OK to lower the backup daemon&#8217;s priority and let it run a little slower.</p>
<p>On Mac OS X Leopard, this is the command that does the trick. From the terminal:</p>
<blockquote><p>
<code>sudo renice +5 -p `ps -axc | grep backupd | awk '{ print \$1 }'`</code>
</p></blockquote>
<p>Here&#8217;s what&#8217;s going on:</p>
<ul>
<li><i>sudo</i> &#8211; This runs the command as the root. You will need to enter the administrator password.</li>
<li><i>renice</i> &#8211; This is the standard Unix command for changing the priority of a running application.</li>
<li><i>+5</i>: Process priorities under BSD Unix-based systems typicall run from -20 to +20, with +20 being <i>lowest</i> (i.e. running slowest) to -20 being maximum (yes, I know it&#8217;s unintuitively backward, but there&#8217;s an old historical reason for it). What we&#8217;re doing is bumping Time Machine daemon&#8217;s nice priority up by 5 (or any number you want) to let it run slower.</li>
<li><i>-p pid</i> &#8211; This is the process id of the process you want to adjust. Since this changes every time Time Machine runs, we have to have a way to find it dynamically at runtime &#8212; which is where the rest of the line enclosed in ` back-quotes come in. On most Unix shells, items enclosed in back-quotes get executed and the result returned back to the command line. So we&#8217;re going to look up the process ID of the current Time Machine server process and return it here.</li>
<li><i>ps -axc</i> &#8211; The <i>ps</i> command returns a long list of all running processes on the system. We need to filter out the one we want, which we do by piping the output into a <em>grep</em> filter next&#8230;</li>
<li><i>grep backupd</i> &#8211; We&#8217;re taking all the output from the <i>ps</i> command and only keeping those lines that contain the string <i>backupd</i> &#8212; which happens to be the name of the Time Machine server. So we end up with a single line of <i>ps</i> output that looks something like this:<br />
<blockquote><p><code>19041 ??         1:07.48 backupd</code></p></blockquote>
<p>But what we need is the process ID to pass back up to the <i>renice</i> command. In this case, it&#8217;s the  first number on the line. We need a way to extract only that, which is where <i>awk</i> &#8212; the amazing text processing Swiss-Army knife &#8212; comes in&#8230;</li>
<li><i>awk &#8220;{print \$1 }&#8221;</i> &#8211; By default, <em>awk</em> splits its input into chunks based on whitespace. We&#8217;re simply asking that the first item be returned. Any time you do this, you should apologize to <i>awk</i> for so massively under-utilizing what it can do. It&#8217;s like driving your Formula-1 car down to the grocery store to buy milk. In this case all we&#8217;re doing is asking it to split up some text and return one item to us, something that <i>awk</i> can do practically in its sleep.</li>
</ul>
<p>When you run this, the <i>sudo</i> part of the command will ask you for your admin password, then proceed to do its thing. Put it all together and you&#8217;ve got yourself a simple way to slow down Time Machine so it&#8217;s not such a CPU hog. </p>
<p>If you&#8217;re enterprising, you can put the whole thing into a shell function and run it over and over. The following code goes inside your <code>.bash_profile</code> file.<br />
<blockquote><code><br />
function tmslow {<br />
        &nbsp;&nbsp;&nbsp;&nbsp;echo "Reducing Time Machine priority..."<br />
        &nbsp;&nbsp;&nbsp;&nbsp;sudo renice +5 -p `ps -axc | grep backupd | awk '{ print \$1 }'`<br />
}<br />
</code></p></blockquote>
<p>Start a new terminal session (to make sure the shell function is loaded) then invoke <code>tmslow</code> and enter your admin password. It prints out a little message reminding you what it&#8217;s about to do.</p>
<p>Remember, the <i>renice</i> command doesn&#8217;t stick, so every time you reboot or a new Time Machine session starts, the process goes back to normal priority. There are ways to automate the priority lowering scheme or even make it permanent, but I don&#8217;t recommend doing that. Sometimes, you may want backups to run full-speed.  Unix makes it trivial to do what you want by stringing together some built-in commands.</p>
]]></content:encoded>
			<wfw:commentRss>http://ramin.firoozye.com/2008/11/08/slowing-down-time-machine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)

Served from: ramin.firoozye.com @ 2010-09-09 09:29:59 -->