12

I would like to schedule a task to execute with parameters at a specific time/date in the future.

Does OS X include any such tool (even if it's command-line)? If not, are there any free or relatively cheap tools out there to accomplish this?

5 Answers 5

15

While KeithB's answer is correct, actually, cron is being deprecated in favor of the OS X specific launchd.

Commands to be run via launchd are described in Apple "plists", or property lists, which are really just XML files:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.
com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>  
    <key>Label</key>
    <string>com.apple.periodic-daily</string>
    <key>ProgramArguments</key>
    <array> 
        <string>/usr/sbin/periodic</string>
        <string>daily</string>
    </array>
    <key>LowPriorityIO</key>
    <true/>
    <key>Nice</key>
    <integer>1</integer>
    <key>StartCalendarInterval</key>
    <dict>  
        <key>Hour</key>
        <integer>3</integer>
        <key>Minute</key>
        <integer>15</integer>
    </dict>
</dict>
</plist>

Having said that, it's not a very user friendly (nor Mac-like) way of scheduling commands to be run. This question on SuperUser lists a few GUI alternatives, including:

Lingon Screencap

launchd Editor ($5 Shareware)

Screen Capture

5
  • 3
    It's not a fair characterization that launchd is "proprietary." Apple eagerly open sourced it at launchd.macosforge.org and it has been ported to FreeBSD.
    – ohmantics
    Dec 10, 2010 at 0:51
  • @ohmantics: Ok, fair point. Is "specific" a better description?
    – Josh
    Dec 10, 2010 at 0:56
  • Close enough. :-) Apple created it, but I expect it will see wider adoption across BSD-like OSes.
    – ohmantics
    Dec 10, 2010 at 0:59
  • @calavera: Thanks for the edit. I hate it when documents on major websites are removed like that. I added a new link which is sadly less relevant, it doesn't specifically mention cron being deprecated :-(
    – Josh
    Dec 19, 2010 at 22:19
  • np... unfortunately Apple seems to do it a lot :/ Dec 19, 2010 at 22:48
4

You can also start Automator workflows with iCal if you just want something simple. Otherwise I would do it through launchd.

4
  • The only issue with iCal is that you have to be logged in for the task to run (correct?)
    – Josh
    Dec 8, 2010 at 15:08
  • yes, I think you must be logged in to do this. I would recommend the launchd process over this, but some people would rather just use iCal and are always logged in.
    – jmlumpkin
    Dec 8, 2010 at 17:38
  • iCal is a much easier solution! See the screen caps I posted. I sure can see how they could be intimidating :-)
    – Josh
    Dec 8, 2010 at 19:50
  • just for clarification, your screenshots are for launchd setup, correct?
    – jmlumpkin
    Dec 9, 2010 at 13:14
3

iCal can be used to run AppleScripts, launch applications, and perform tasks to a schedule.

There are limitations to using iCal, but it is included with Mac OS X and relatively easy to set up. The limitations and a visual walk through on how to set up a scheduled AppleScript are included in the link above.

Setting up a scheduled AppleScript with iCal on Mac OS X

2

There are two Unix command-line tools that do what you want. at will allow you to schedule a task to execute once at a specific time in the future. Of course, part of the task could be to schedule another task.

cron allows you to schedule tasks to regularly execute at the same time, based on time of day, day of the week, etc.

One thing to note is that both of these will not run tasks if your machine is not running at the time they are scheduled. There are alternatives, such as anacron, that will run scheduled tasks the next time the machine boots.

1
  • 2
    Note that, by default, the "at" command is disabled. Use "man atrun" to figure out how to enable it. Feb 2, 2011 at 4:24
2

Scheduler for MacIntosh is a gui-based task scheduler for macOS can be downloaded at https://macscheduler.net/. Been using it to run a backup app I wrote. Runs in background, doesn't need to be opened at startup. Can launch apps, scripts, docs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .