<?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>Zenovation's Blog &#187; cron</title>
	<atom:link href="http://zenovations.com/blog/tag/cron/feed/" rel="self" type="application/rss+xml" />
	<link>http://zenovations.com/blog</link>
	<description>A blog about web design, programming, hosting, and virtualmin hacks</description>
	<lastBuildDate>Mon, 16 Jan 2012 15:01:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Run a Cygwin Command From Windows Scheduler (Scheduled Tasks)</title>
		<link>http://zenovations.com/blog/2009/06/how-to-run-a-cygwin-command-from-windows-scheduler-scheduled-tasks/</link>
		<comments>http://zenovations.com/blog/2009/06/how-to-run-a-cygwin-command-from-windows-scheduler-scheduled-tasks/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 19:42:31 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=125</guid>
		<description><![CDATA[After repeated problems setting up crond to run in cygwin (it just doesn&#8217;t like the user accounts, no matter how enthusiastically I argue that I&#8217;m me), I spent some time figuring out how to run a Cygwin command as a scheduled task from Windows. Based on this mail archive post, I created the following cygrun.bat [...]]]></description>
			<content:encoded><![CDATA[<p>After repeated problems setting up crond to run in cygwin (it just doesn&#8217;t like the user accounts, no matter how enthusiastically I argue that I&#8217;m me), I spent some time figuring out how to run a Cygwin command as a scheduled task from Windows.</p>
<p>Based on <a href="http://www.mail-archive.com/cygwin@cygwin.com/msg71014.html">this mail archive post</a>, I created the following cygrun.bat file:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p125code4'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1254"><td class="code" id="p125code4"><pre class="bash" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">echo</span> off
    rem <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">HOME</span>=c:\
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #ff0000;">&quot;%DEF_PATH%&quot;</span>==<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">DEF_PATH</span>=<span style="color: #000000; font-weight: bold;">%</span>PATH<span style="color: #000000; font-weight: bold;">%</span>
    <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">PATH</span>=c:\cygwin\bin;<span style="color: #000000; font-weight: bold;">%</span>DEF_PATH<span style="color: #000000; font-weight: bold;">%</span>
    <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">myargs</span>=<span style="color: #000000; font-weight: bold;">%*</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #ff0000;">&quot;%myargs%&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> goto noarg
    rem <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">%</span>myargs<span style="color: #000000; font-weight: bold;">%</span>
    <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">--rcfile</span> <span style="color: #ff0000;">&quot;%HOME%/.bashrc&quot;</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;%myargs%&quot;</span>
    c:
    rem pause
    <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
    goto <span style="color: #7a0874; font-weight: bold;">exit</span>
    :noarg
&nbsp;
    rxvt <span style="color: #660033;">-e</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">--login</span> <span style="color: #660033;">-i</span>
&nbsp;
    :<span style="color: #7a0874; font-weight: bold;">exit</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span></pre></td></tr></table></div>

<p>Then I tested the script from the command line as follows, until I had the syntax just so:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p125code5'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1255"><td class="code" id="p125code5"><pre class="bash" style="font-family:monospace;">c:
<span style="color: #7a0874; font-weight: bold;">cd</span> \cygwin
cygrun.bat cygwin_script arg1 arg2</pre></td></tr></table></div>

<p>Once I was able to run it happily, I added the scheduled task as follows:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p125code6'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1256"><td class="code" id="p125code6"><pre class="bash" style="font-family:monospace;">    Run: C:\WINDOWS\system32\CMD.EXE <span style="color: #000000; font-weight: bold;">/</span>x <span style="color: #000000; font-weight: bold;">/</span>c start <span style="color: #ff0000;">&quot;Some title&quot;</span> <span style="color: #000000; font-weight: bold;">/</span>min
c:\cygwin\cygrun.bat cygwin_script arg1 arg2
    Start In: c:\cygwin     <span style="color: #000000; font-weight: bold;">&amp;</span>lt;-- must be a real disk drive and path
    Run <span style="color: #c20cb9; font-weight: bold;">as</span>: domain\username</pre></td></tr></table></div>

<p>Unfortunately, I was never able to figure out how to redirect stdout and stderr. I tried plenty of variations on &#8220;&gt;&gt; /some/path/to/log.txt 2&gt;&amp;1&#8243; with no joy. Instead, I just changed all the commands in the script and added that line on to each echo statement. Sad, but functional.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/06/how-to-run-a-cygwin-command-from-windows-scheduler-scheduled-tasks/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Getting Cron to Run in Cygwin</title>
		<link>http://zenovations.com/blog/2009/05/getting-cron-to-run-in-cygwin/</link>
		<comments>http://zenovations.com/blog/2009/05/getting-cron-to-run-in-cygwin/#comments</comments>
		<pubDate>Fri, 08 May 2009 19:44:37 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cygwin]]></category>

		<guid isPermaLink="false">http://zenovations.com/blog/?p=51</guid>
		<description><![CDATA[I had problems getting cron to run under cygwin. I could crontab -e and install scripts, but they never actually get run. The first step was to install cygrunsrv, which appears under the admin section of cywin&#8217;s setup.exe package list. A little searching revealed a utility that will check your set up and install crontab [...]]]></description>
			<content:encoded><![CDATA[<p>I had problems getting cron to run under cygwin. I could <code>crontab -e</code> and install scripts, but they never actually get run.</p>
<p>The first step was to install <code>cygrunsrv</code>, which appears under the admin section of cywin&#8217;s setup.exe package list.</p>
<p>A little searching revealed a utility that will check your set up and install crontab for you. Here&#8217;s the complete steps I found by runnning this utility repeatedly and researching the errors it reported:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code9'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p519"><td class="code" id="p51code9"><pre class="bash" style="font-family:monospace;">kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+r <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+r <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>group
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> a+x <span style="color: #000000; font-weight: bold;">/</span>var
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ cron_diagnose.sh
Do you want to <span style="color: #c20cb9; font-weight: bold;">install</span> the cron daemon <span style="color: #c20cb9; font-weight: bold;">as</span> a service? <span style="color: #7a0874; font-weight: bold;">&#40;</span>yes<span style="color: #000000; font-weight: bold;">/</span>no<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
Enter the value of CYGWIN <span style="color: #000000; font-weight: bold;">for</span> the daemon: <span style="color: #7a0874; font-weight: bold;">&#91;</span>ntsec smbntsec<span style="color: #7a0874; font-weight: bold;">&#93;</span> ntsec
&nbsp;
The service can run either <span style="color: #c20cb9; font-weight: bold;">as</span> yourself or under a privileged account.
Running <span style="color: #c20cb9; font-weight: bold;">as</span> yourself allows better access to network drives,
but does not allow to run the crontab of other users.
Do you want to the cron daemon to run <span style="color: #c20cb9; font-weight: bold;">as</span> yourself? <span style="color: #7a0874; font-weight: bold;">&#40;</span>yes<span style="color: #000000; font-weight: bold;">/</span>no<span style="color: #7a0874; font-weight: bold;">&#41;</span> no
&nbsp;
Running cron_diagnose ...
... no problem found.
&nbsp;
Do you want to start the cron daemon <span style="color: #c20cb9; font-weight: bold;">as</span> a service now? <span style="color: #7a0874; font-weight: bold;">&#40;</span>yes<span style="color: #000000; font-weight: bold;">/</span>no<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #c20cb9; font-weight: bold;">yes</span>
OK. The cron daemon is now running.</pre></td></tr></table></div>

<p>In my particular case, I also had to run the following, though take care with these since they replace your /etc/passwd file:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p51code10'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5110"><td class="code" id="p51code10"><pre class="bash" style="font-family:monospace;">kato<span style="color: #000000; font-weight: bold;">@</span>devbox ~$ mkpasswd <span style="color: #660033;">-l</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><span style="color: #c20cb9; font-weight: bold;">passwd</span>
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox ~$ mkgroup <span style="color: #660033;">-l</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>group
&nbsp;
kato<span style="color: #000000; font-weight: bold;">@</span>devbox  ~$ mkpasswd <span style="color: #660033;">-d</span> <span style="color: #660033;">-u</span> kato <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://zenovations.com/blog/2009/05/getting-cron-to-run-in-cygwin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

