macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

An Introduction to Tiger Terminal, Part 5
Pages: 1, 2, 3, 4, 5

How to Edit launchd Agent plists

Like most things, you have a choice between the CLI and the GUI. Graphically, you can use a plist editor to view and edit plist files. If you have Apple Developer Tools installed, you will have Property List Editor in /Developer/Applications. There is also a very nice third party developer plist editor specifically for launchd plist editing called Launchd Editor by codepoetry. This is a $5 shareware app and well worth it.



Read the man pages for the cryptically called launchd.plist for options and parameters (launchd.plist doesn't actually exist; it's merely a reference name).

Go to /System/Library/LaunchDaemons and double-click the com.apple.periodic-daily.plist file. It should automatically open Property List Editor.

figure 16
Figure 16. com.apple.periodic-daily.plist in Property List Editor

There are over 30 different keys that can be set (and, IMHO, the syntax is ugly). The most important are Label and Program or ProgramArguments. The Label needs to be unique and Apple prefers (but doesn't require) that you use a domain scheme for naming. The Program or ProgramArguments key indicates the path to the executable that you want to run. The difference between the two lies in how you choose to specify any arguments: if you choose to use Program, you give the full path to the program and then indicate the arguments in ProgramArguments; if you choose to use only ProgramArguments, the first value in the array is the executable (see /usr/sbin/periodic in Figure 16, above) and the subsequent array values are arguments (see daily in Figure 16, above).

Using Launchd Editor: File - Open, navigate to the file (or: navigate to the file, control-click it, select Open With... and choose Launchd Editor).

figure 17
Figure 17. com.apple.periodic-daily.plist in Launchd Editor, General tab

figure 18
Figure 18. com.apple.periodic-daily.plist in Launchd Editor, Startup tab

figure 19
Figure 19. com.apple.periodic-daily.plist in Launchd Editor, Configuration tab

Remember that these files belong to the global system so don't mess with these jobs! The StartCalendarInterval key specifies when the job will be run. This launch daemon, com.apple.periodic-daily.plist, runs its corresponding scripts in the /etc/periodic/daily directory: 100.clean-logs and 500.daily. If you want to run these outside of the hours indicated in the plist file (i.e. on demand), you can use the periodic command.

figure 20
Figure 20. Run the daily/weekly/monthly jobs

You'll be asked for your password.

figure 21
Figure 21. Enter your password

The jobs will take several minutes to run.

figure 22
Figure 22. Jobs running

You'll be put back at the command prompt when the jobs have completed.

Pages: 1, 2, 3, 4, 5

Next Pagearrow