Create a gist now

Instantly share code, notes, and snippets.

@fspaolo /
Last active Aug 9, 2017

What would you like to do?

Grid computing with Apple's Xgrid

How to set up a grid of computers using the Mac OS X desktop version.

The Xgrid agent (worker)

Any machine can be an agent. Configure the agent using the Sharing Pane of System Preferences. See Managing Xgrid Agents.

The Xgrid controller (master)

Configuration is straightforward on Mac OS X Server. However, on the desktop version use the XgridLite open source software to:

  • Turn on and off the built-in Xgrid controller with a single click
  • Set passwords for client and agent authentication
  • Reset the controller to default settings

See Managing an Xgrid Controller.

The Xgrid Daemon Control Interface

Command line:

$ xgridctl

Start the controller:

$ ssh
$ sudo xgridctl c start

Turn off an agent:

$ ssh
$ sudo xgridctl a stop

More options:

$ sudo xgridctl
usage: xgridctl [controller|agent] status|start|stop|restart

The Xgrid Admin tool

Provides a summary of the activity of the grid. This software is part of Mac OS X Server. Download it for free from Apple's website.

A hack for Snow Leopard

To have read/write permission on the agents in /Volumes we need kerberos. But it is only available on Mac OS X Server. Instead... one can simply change the configuration files:

$ sudo cp /usr/share/sandbox/ /usr/share/sandbox/
$ sudo cp /usr/share/sandbox/ /usr/share/sandbox/ 

The xgrid command-line client (user)

Set the environmental variables (or add these to your .bashrc):


Client submit jobs to the controller:

$ xgrid -job submit /usr/bin/python -O

{jobIdentifier = 231; }

Client queries the results:

$ xgrid -job results -id 231 

Agent jobs

What is copied to the agents?

  • The Command (if relative path): /tmp/xgagent.GSI0Z6o4/bin/sh
  • The Working dir (if relative path): /tmp/xgagent.bUDiNL4g

Client results

What is copied back to the client?

  • The stdout stream
  • The stderr stream
  • The working dir

Submitting multiple jobs

For single task jobs, simply let the controller managing the jobs:

$ xgrid -job submit /usr/bin/python
$ xgrid -job submit /usr/bin/python
$ xgrid -job submit /usr/bin/python

Running batch jobs

For multiple task jobs, you can use the following scripts to create and send batch files to the controller, and to retrive the results:

Notice that the xgrid command line tool does not support "globbing" multiple files as argument (e.g. *.ext). For that purpose I wrote the above scripts.

To generate and submit a batch file with jobs that call a program prog with command line argument arg on several files:

$ python -s -j jobname -c "/path/to/prog -a arg" /path/to/files/*.ext

To retrieve the results by passing the ID files (generated by

$ python ... 

Or by passing the directory containing those files:

$ python /path/to/directory

More info


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment