Solved

Using cron jobs on a mac

Posted on 2010-11-19
4
1,017 Views
Last Modified: 2012-05-10
How do I schedule cron jobs on a mac? Is there a gui interface provided by apple for scheduling tasks on a mac, or should I just the cron command line like how you'd do it in linux?

And, this might be a silly question, but once you've scheduled a cron job, does it run regardless of whether a user is logged in or not? Or does someone have to actually be logged into the mac for it to run?

If the cron job will run without anyone being logged in, under what user credentials does it run? root?
0
Comment
Question by:Frosty555
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
et01267 earned 167 total points
ID: 34173070
First, launchd has sort of replaced cron, but cron still can be used.  The cron daemon is started automatically when the system notices there are crontab files created in the proper place.  There seems to be a GUI for MacOS here, but I've never used it.

You can set up cron jobs just like on linux -- OSX is unix under the hood.  Just open the Terminal app (under Applications -> Utilities) and you're in a unix shell.

If you are logged in with an admin-capable account, you can set up cron jobs for root (assuming you know how to edit with vi) with

sudo crontab -e

Open in new window


or to set up a cron job for another user

sudo crontab -u <user> -e

Open in new window


If you are trying to set up a cron job for the user your are logged in as, then just do

crontab -e

Open in new window


Cron jobs will run when scheduled regardless of anyone being logged in or not.  The jobs run under the credentials / permissions of the user to which the job belongs.  So in the first example, the jobs run as root, in the second they run under <user>, and in the last they run under the user you are logged in as.

Check the man pages for cron and crontab.

There are GUI tools that make this somewhat easier.
0
 
LVL 32

Assisted Solution

by:nappy_d
nappy_d earned 166 total points
ID: 34180295
CronX is the tool you are looking for.
0
 
LVL 32

Expert Comment

by:nappy_d
ID: 34180369
0
 
LVL 12

Assisted Solution

by:nxnw
nxnw earned 167 total points
ID: 34180478
Or you can use lingon to schedule jobs using launchd (which the mac OS now uses instead of cron). It is more powerful and flexible than cron.

http://sourceforge.net/projects/lingon/
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Steve Jobs once said that Blu-ray is "a bag of hurt". As Macs users well known, things haven’t settled down (at least not from Apple’s perspective). Several years after that comment, Mac OS X still doesn’t support Blu-ray playback, nor has any Mac s…
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question