Solved

Using cron jobs on a mac

Posted on 2010-11-19
4
1,102 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A common question or need, when setting-up a new Mac for someone would be to make all of the applications, installed, available from the dock. Many people often do not realize an application is installed unless it is in the dock. Creating a custo…
There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
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…

739 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