Solved

Using cron jobs on a mac

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Syslogd is a utility that traps and logs messages sent by running processes. It is configured with the syslog.conf file, which consists of lines containing a pair of fields: "the selector field which specifies the types of messages and priorities to…
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
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…

760 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

22 Experts available now in Live!

Get 1:1 Help Now