How to Leverage Automator to Work the Same Way as Crontab

After struggling for a long time with trying to make my crontab work, I eventually gave up and sought out a different method to setup an automated way for my script to run. I came across multiple articles online mentioning Automator, a MacOS application that allows you to automate certain functions on your computer. Many of these guides mentioned creating an Automator job and then scheduling it to recur via iCal.

Here is how I went about doing that:

  1. I opened Automator via Spotlight:

    For our purposes, since we want this to run on its own, I created a new Automator Application (File → New or Cmd+N and then select Application):

    Automator Applications are self-running whereas Automator Workflows require user inputs to kick off.

    Now let’s go over this screen a bit, because it was very confusing to me when I first opened this application:

    Within the application, you have three main panels. The far left panel with the expandable/collapsable directories is a way to navigate through the different actions available for automation. When you first open a new file in Automator, you are automatically placed at the top of this directory (Library) and all actions are displayed.

    The second panel, the one in the middle, is where the individual actions for automation are accessible. You can scroll up and down to see some of the actions at your disposal: you can launch an application, copy and paste files from one folder to another, download URLs, or do many other things using the actions in this column.

    The third panel on the far right of the screen is the workflow panel. This allows you to build your workflow using the actions in the middle panel. This is where Automator becomes really powerful since it allows you to string together simple actions to form complex workflows: you can download URLs, then copy the files downloaded from one directory to another, and then launch a script to run a process on those newly transferred files. In order to build these workflows, you drag and drop actions from the middle panel into the far right panel.

    At the top right corner, you have Record, Step, Stop, and Run buttons that will assist in checking your workflow once you have something down.

  2. For my Automator Application, I wanted to run a Shell script. So, I filtered the left panel directory to Utilities, then searched for the “Run Shell Script” command in the middle panel, and dragged it into the right panel to create my workflow:

  3. My next step was to customize my step. So, in the step panel, I entered my Terminal code for running my Shell script:
    /Users/mnachum/Desktop/./ >> /tmp/log.log

  4. I then ran my Application to verify that it worked:

    Checking the logs within Automator, everything seemed to have worked as expected. I also checked the outputted logs from my command (/tmp/log.log) and verified that those looked correct, as well.

    I saved my Application:

  5. I now had my Automator Application running my desired task, but I needed to schedule it to run regularly without input from me. Many forums online mentioned being able to create an appointment in iCal and then connecting that appointment to the running of the workflow, but this seemed like outdated advice to me. When searching for this functionality in the current iCal interface, I could not find a way to make appointments or events that linked to applications or scripts.

    However, I did note in Automator the ability to create an event in iCal that would launch an application. To get to this option, I opened a new Automator Workflow…

    …filtered to Calendar events in the directory panel, and dragged and dropped the “New Calendar Event” option into my Workflow.  Under the “Alarm” dropdown, there’s an option to “Open file”:

    I configured my New Calendar Event to open my previously configured Automator Application:

    Once the “Open file” option is selected under the “Alarm” field, an application needs to be selected. I selected my previously saved Automator Application.

  6. With my scheduling Workflow completed, I ran the Workflow:

    …and verified that the Event was added to my iCal, as expected:

    Whether or not you save this workflow is up to you. My desired outcome for this Automator Workflow was completed but I still decided to save my Workflow in case I needed to troubleshoot.

  7. From my iCal, I can now configure the Event to recur:

And that’s it!  That’s how I was able to stop using crontab to run my scripts and instead started using a combination of Automator Applications/Workflows and iCal Events. Note that from my experience, the Automator and iCal applications do not need to be open in order for the automated job to complete.

When the Automator Application does run, you will be able to see that it is running via the appearance of a sun-like icon in the toolbar:

Blog at