Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using cron jobs on a mac

Posted on 2010-11-19
4
Medium Priority
?
1,230 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 668 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 664 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 668 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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 > …
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…

715 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