Solved

Using cron jobs on a mac

Posted on 2010-11-19
4
975 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article describes in detail how to set up the iPad in the Enterprise using iPCU aka iPhone Configuration Utility.  This could also be used for the iPhone although I have not detailed out any differences. Preparation as an iPad Administrator:…
In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
Users will learn how resize a batch of photos from a single command in Photoshop via Photoshop's Image Processor. Open up an Image you'd like to resize in Adobe Photoshop: Adjust the image size according to your preferences. Image > Adjustments > …
Users will learn how to set proper sequence settings, scale images, paste attributes, add transitions, fades, and music. Open up Final Cut Pro 7 and Create a new Project: Set the Sequence Settings. a) Click File > Easy Setup > Format > Apple ProRe…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now