<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Scheduling a 1-time future job in OSX?</title>
	<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX/</link>
	<description>Comments on Ask MetaFilter post Scheduling a 1-time future job in OSX?</description>
	<pubDate>Sun, 11 May 2008 04:38:45 -0800</pubDate>
	<lastBuildDate>Sun, 11 May 2008 04:38:45 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Scheduling a 1-time future job in OSX?</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX</link>	
		<description>Mac OS X (Leopard): at(1) replacement? &lt;br /&gt;&lt;br /&gt; I need to run a shell script, once, at a specified time in the future (ideally, I&apos;d like to be able to specify &quot;X minutes from now, do this&quot;, equivalent to &quot;at now+X minutes&quot;).  &lt;br&gt;
&lt;br&gt;
However, at(1) is broken on OS X (and it&apos;s not just because atrun is disabled: at&apos;s got some serious time conversion errors) and I can&apos;t figure out how to do this via launchd.&lt;br&gt;
&lt;br&gt;
Running 10.5.2 if it makes a difference.&lt;br&gt;
&lt;br&gt;
Short of using sleep, is there an easy way to queue jobs up for future processing but make it so that the job is only run once, then dequeued/deleted?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.91106</guid>
		<pubDate>Sun, 11 May 2008 04:17:24 -0800</pubDate>
		<dc:creator>aberrant</dc:creator>
		
			<category>osx</category>
		
			<category>mac</category>
		
			<category>at</category>
		
			<category>sleep</category>
		
			<category>job</category>
		
			<category>scheduling</category>
		
	</item> <item>
		<title>By: sophist</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336362</link>	
		<description>I think you want to do this with cron.  Googling cron and osx should lead you down the correct path, but here are a few top hits anyway [&lt;a href=&quot;http://www.oreilly.com/pub/a/mac/2001/12/14/terminal_one.html&quot;&gt;1&lt;/a&gt;, &lt;a href=&quot;http://www.osxfaq.com/man/5/crontab.ws&quot;&gt;2&lt;/a&gt;, &lt;a href=&quot;http://lists.apple.com/archives/Macos-x-server/2003/Apr/msg01528.html&quot;&gt;3&lt;/a&gt;] and &lt;a href=&quot;http://quicksilver.caup.washington.edu/software/Crontooie/&quot;&gt;here&lt;/a&gt; is a small utility GUI which promises to work although I have no firsthand knowledge of said promise!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336362</guid>
		<pubDate>Sun, 11 May 2008 04:38:45 -0800</pubDate>
		<dc:creator>sophist</dc:creator>
	</item><item>
		<title>By: dseaton</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336369</link>	
		<description>Agree, cron is the way to do this, and &lt;a href=&quot;http://www.abstracture.de/projects-en/cronnix&quot;&gt;CronniX&lt;/a&gt; is the best tool for the job.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336369</guid>
		<pubDate>Sun, 11 May 2008 05:12:37 -0800</pubDate>
		<dc:creator>dseaton</dc:creator>
	</item><item>
		<title>By: aberrant</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336424</link>	
		<description>Sorry if I wasn&apos;t clearer: cron won&apos;t do what I want because it&apos;s difficult to set it up to schedule a one-time job (how do you automatically remove a cron entry easily)?  and the GUI frontends are not useful because I&apos;m scripting the whole thing.  I need to programatically submit jobs to run once in the future.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336424</guid>
		<pubDate>Sun, 11 May 2008 08:19:48 -0800</pubDate>
		<dc:creator>aberrant</dc:creator>
	</item><item>
		<title>By: ijoshua</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336437</link>	
		<description>iCal has the option to run a script on an event&apos;s alarm.  I don&apos;t know how it will handle an event that would have occurred while the computer was asleep.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336437</guid>
		<pubDate>Sun, 11 May 2008 08:47:04 -0800</pubDate>
		<dc:creator>ijoshua</dc:creator>
	</item><item>
		<title>By: ijoshua</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336438</link>	
		<description>Oh, I missed your reply that your entire workflow is scripted.  Perhaps you could use AppleScript to create iCal events with alarms?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336438</guid>
		<pubDate>Sun, 11 May 2008 08:48:18 -0800</pubDate>
		<dc:creator>ijoshua</dc:creator>
	</item><item>
		<title>By: dreadpiratesully</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336442</link>	
		<description>If you use launchd instead of cron, I don&apos;t think you can set up a one-time job but it&apos;s easy to programatically remove the job - &apos;launchctl remove jobname&apos;.  You could use a script that does whatever you need it to and then removes itself from launchd, or at least disables itself.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336442</guid>
		<pubDate>Sun, 11 May 2008 08:53:33 -0800</pubDate>
		<dc:creator>dreadpiratesully</dc:creator>
	</item><item>
		<title>By: namewithoutwords</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336453</link>	
		<description>cron has enough granularity that you can specify the job only run once, ever....&lt;br&gt;
&lt;br&gt;
as far as removing entries programatically, why not simply overwrite the crontab for the user in question with a new one every time you need to run a new job?  have the script dump the cron entry out to a (temp) file, and then call crontab to read that file in?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336453</guid>
		<pubDate>Sun, 11 May 2008 09:08:38 -0800</pubDate>
		<dc:creator>namewithoutwords</dc:creator>
	</item><item>
		<title>By: Mikey-San</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336463</link>	
		<description>&lt;i&gt;However, at(1) is broken on OS X&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
Define &quot;broken&quot;?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336463</guid>
		<pubDate>Sun, 11 May 2008 09:18:13 -0800</pubDate>
		<dc:creator>Mikey-San</dc:creator>
	</item><item>
		<title>By: aberrant</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336480</link>	
		<description>From the bug report I submitted:&lt;br&gt;
&lt;br&gt;
* SUMMARY&lt;br&gt;
at(1) is queueing jobs with the same jobid (688128) and wildly incorrect times.&lt;br&gt;
&lt;br&gt;
sh-3.2# ls -l /usr/bin/at; md5 /usr/bin/at&lt;br&gt;
-r-sr-xr-x  4 root  wheel  69552 Dec 10 14:40 /usr/bin/at&lt;br&gt;
MD5 (/usr/bin/at) = 9960f880ca5fe80853ec9adee0494479&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
* STEPS TO REPRODUCE&lt;br&gt;
One example:&lt;br&gt;
echo &quot;ls&quot; | at now+5 minutes&lt;br&gt;
&lt;br&gt;
* RESULTS&lt;br&gt;
sh-3.2# date; echo &quot;ls&quot; | at now+5 minutes&lt;br&gt;
Sun May 11 09:11:05 PDT 2008&lt;br&gt;
job 11 at Sun May 11 09:16:00 2008&lt;br&gt;
sh-3.2# at -l&lt;br&gt;
688128	Tue Sep 24 21:01:12 1912&lt;br&gt;
&lt;br&gt;
expected:&lt;br&gt;
&lt;br&gt;
sh-3.2# at -l&lt;br&gt;
11 Sun 11 May 09:16:00 2008&lt;br&gt;
&lt;br&gt;
* REGRESSION&lt;br&gt;
Problem occurs consistently, but the queue time differs.&lt;br&gt;
&lt;br&gt;
* NOTES&lt;br&gt;
May be related to the bug in leave(1) (bug ID 5835373).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336480</guid>
		<pubDate>Sun, 11 May 2008 09:37:57 -0800</pubDate>
		<dc:creator>aberrant</dc:creator>
	</item><item>
		<title>By: sergent</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336481</link>	
		<description>I think that at works, but it&apos;s the BSD at, not the GNU one, so it may not accept all the command line flags that you think it does.  Have you read the man page?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336481</guid>
		<pubDate>Sun, 11 May 2008 09:39:19 -0800</pubDate>
		<dc:creator>sergent</dc:creator>
	</item><item>
		<title>By: sergent</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336482</link>	
		<description>Hm, I&apos;m probably wrong.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336482</guid>
		<pubDate>Sun, 11 May 2008 09:40:52 -0800</pubDate>
		<dc:creator>sergent</dc:creator>
	</item><item>
		<title>By: aberrant</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336486</link>	
		<description>Yeah, read the manpage, this should work.  Nothing submitted to at(1) is queued at the proper time.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336486</guid>
		<pubDate>Sun, 11 May 2008 09:43:21 -0800</pubDate>
		<dc:creator>aberrant</dc:creator>
	</item><item>
		<title>By: sergent</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336487</link>	
		<description>Anyway, you could still write your own cheap version of at in a shell script and run it as a cron job.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336487</guid>
		<pubDate>Sun, 11 May 2008 09:43:28 -0800</pubDate>
		<dc:creator>sergent</dc:creator>
	</item><item>
		<title>By: sergent</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336494</link>	
		<description>Well, I found the bug.  The source code is  &lt;a href=&quot;http://www.opensource.apple.com/darwinsource/10.5.2/system_cmds-433/at.tproj/&quot;&gt;here&lt;/a&gt;.  The stupid makefile sets -DDEFAULT_AT_QUEUE to \&quot;a\&quot; instead of \&apos;a\&apos;, which breaks everything.  You can work around this by adding the &apos;-q a&apos; flag, or by fixing the makefile.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336494</guid>
		<pubDate>Sun, 11 May 2008 09:57:14 -0800</pubDate>
		<dc:creator>sergent</dc:creator>
	</item><item>
		<title>By: aberrant</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336501</link>	
		<description>FANTASTIC.  Just updated the bug report.  Thanks, sergent!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336501</guid>
		<pubDate>Sun, 11 May 2008 10:04:12 -0800</pubDate>
		<dc:creator>aberrant</dc:creator>
	</item><item>
		<title>By: ctmf</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336568</link>	
		<description>Wow.  AskMe above and beyond.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336568</guid>
		<pubDate>Sun, 11 May 2008 11:59:55 -0800</pubDate>
		<dc:creator>ctmf</dc:creator>
	</item><item>
		<title>By: sbutler</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336576</link>	
		<description>Ooooh... good catch. DEFAULT_BATCH_QUEUE also needs to be changed then.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336576</guid>
		<pubDate>Sun, 11 May 2008 12:03:02 -0800</pubDate>
		<dc:creator>sbutler</dc:creator>
	</item><item>
		<title>By: aberrant</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336620</link>	
		<description>Yup.  Already added to the bug report.  Hopefully this can be fixed.&lt;br&gt;
&lt;br&gt;
leave(1) is suffering from possibly similar timing issues, but to the best of my knowledge, it&apos;s not using at(1).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336620</guid>
		<pubDate>Sun, 11 May 2008 13:07:23 -0800</pubDate>
		<dc:creator>aberrant</dc:creator>
	</item><item>
		<title>By: sergent</title>
		<link>http://ask.metafilter.com/91106/Scheduling-a-1time-future-job-in-OSX#1336921</link>	
		<description>Just in case it wasn&apos;t clear from my earlier comment, you can use &lt;tt&gt;at -q a&lt;/tt&gt; instead of &lt;tt&gt;at&lt;/tt&gt; to work around the problem.  The bug is just in the setting of default for the &quot;-q&quot; flag - the Makefile is setting the default to a string instead of a character, and C just omits a compiler warning for this rather than failing to compile, and Apple evidently doesn&apos;t use -Werror.&lt;br&gt;
&lt;br&gt;
I&apos;m pretty sure that leave is having a different problem, since it takes no command line flags.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.91106-1336921</guid>
		<pubDate>Sun, 11 May 2008 22:17:09 -0800</pubDate>
		<dc:creator>sergent</dc:creator>
	</item>
	</channel>
</rss>
