mac os x

Scheduled Jobs with Launch Daemons-Agents and plist Files

SOFTWARE: mac os x


Mac OS X Version: 10.4 +

Launchd seems to have replaced cron on mac os x at this point. Here are tips on using launchctl to activate/deactivate existing jobs, and also how to create your own jobs.

Load/Unload Existing Daemons

Use launchctl to add/remove startup items. Find full usage here:

launchctl manual

To load:

sudo launchctl load -w /path/to/daemon

To unload:

sudo launchctl unload -w /path/to/daemon

Example with Macports Existing plist files

Startup items (at least for macports installs) are symlinks to .plist format files inside:


I've noticed that if you upgrade a macport --like mysql5 or apache2 for instance-- sometimes the startup item that kicks it off on boot up goes away. To fix this, look inside /Library/LaunchDaemons and find the names of the .plist files you have. I had these symlinks:


I added them back as startup items with these commands:

 sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist


sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist

And now both apache and mysql get fired up on boot up again.

Creating and Activating Your Own plist Files

launchd.plist manual

For timed jobs on the mac:

  • Create dir ~/Library/LaunchAgents
  • Create a file in the new dir called something like ???com.mydomain.sync.plist???

Contents for your plist file would be like this (see below) for a scheduled job called ???com.mydomain.sync.plist??? which runs the file ??? at 9:00am every day (that the machine is powered on):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
  • Activate it with: launchctl load ~/Library/LaunchAgents/com.mydomain.sync.plist

  • Make sure to add an explicit ???exit 0??? to your shell script so launchd knows that it ran. Otherwise it???ll keep attempting to run it over and over.

  • I think the naming convention of "com.mydomain.whatitdoes.plist" is for organizing lots of xml files. You replace "mydomain" with something logical for you, and likewise for the "whatitdoes" part.


flush dns cache

SOFTWARE: mac os x

lookupd -flushcache

Mac OS X - Flush DNS Cache


lookupd -flushcache


dscacheutil -flushcache


/etc/rc.d/init.d/nscd restart


ipconfig /flushdns

Switch Tabs in Terminal (10.5)

SOFTWARE: mac os x

Command Key + Shift + Right/Left Arrows

To switch between tabs in the terminal:

Command Key + Shift + Right/Left Arrows

create iso > burn disc

SOFTWARE: mac os x

hdiutil makehybrid -o yournewiso_name /Path/To/Disc

Mac OS X Leopard

To use the command line to copy a disc, first create an iso file from the disc, then after that finishes, insert a blank disc and burn the blank disc with the iso file you just made. You'll be using the hdiutil command in the terminal to do this.

Create iso file

Insert your disc you want to copy.

Change directory to where you want to create the new iso file. IE to change to your current user's Documents folder:

cd ~/Documents

Then run hdiutil to make a "hybrid" iso that can run on different os's. After the -o flag designate the name of your iso file minus the .iso suffix, then designate the full path to the disc you've inserted. If the disc name include spaces, wrap it in quotes:

hdiutil makehybrid -o your_new_iso_name /Path/To/"Disc Name"


hdiutil makehybrid -o myimage /Volumes/"Backup Files"

Burn to new disc

Use the burn command and simply designate the full path the the iso you created above. Assuming you just have one burner hooked up to your machine, you don't have to tell it which burner to use so it's just:

hdiutil burn /Path/To/your_iso_file.iso


hdiutil burn ~/Documents/myimage.iso

There are many additional options to hdiutil if you need them. You can find the full docs by typing this in your terminal:

man hdiutil

vmware fusion duplicate entries

SOFTWARE: mac os x

mv "/Users/${USER}/Library/Preferences/com.vmware.fusion.plist" "/Users/${USER}/Library/Preferences/(...)

To get rid of duplicate entries in the fusion library. Generate a fresh plist file so your vmware fusion library populates correctly after system/fusion upgrades:

mv "/Users/${USER}/Library/Preferences/com.vmware.fusion.plist"