Tags:
create new tag
view all tags
ALERT! NOTE: This is a SupplementalDocument topic which is not included with the official TWiki distribution. Please help maintain high quality documentation by fixing any errors or incomplete content. Put questions and suggestions concerning the documentation of this topic in the comments section below! Use the Support web for problems you are having using TWiki.

FAQ:

How do I set up cron jobs on Mac OS X?

Answer:

Mac OS X 10.4.x and newer recommends launchd instead of cron. The user needs to create a .plist in /System/Library/LaunchDaemons. The example here is for launching mailnotify from the MailerContrib, but the pattern applies to all cron jobs.

I named it com.apple.twiki-mailnotify-launchd.plist. The file should look like this, if named similarly to mine:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://d8ngmj9uuucyna8.roads-uae.org/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>com.apple.twiki-mailnotify-launchd</string>
   <key>Program</key>
   <string>/usr/bin/perl</string>
   <key>ProgramArguments</key>
   <array>
      <string>perl</string>
      <string>-I</string>
      <string>/Library/WebServer/twiki/bin</string>
      <string>/Library/WebServer/twiki/tools/mailnotify</string>
      <string>-q</string>
   </array>
   <key>ServiceDescription</key>
   <string>Launch Daemon for the Twiki Mail Notification System</string>
   <key>StartInterval</key>
   <integer>120</integer>
</dict>
</plist>

StartInterval/120 means run the script every two minutes.

Once the file has been saved in /System/Library/LaunchDaemons/ and permissions are set correctly, load the plist to the launchd queue by executing this at the command line:

launchctl load /System/Library/LaunchDaemons/com.apple.twiki-mailnotify-launchd.plist

Back to: TWikiFAQ

-- Contributors: JustinMaxwell, CrawfordCurrie



Comments & Questions about this Supplemental Document Topic

Whats a Cron?

-- JackJarman - 20 Nov 2007

Wikipedia:Cron

-- FranzJosefGigler - 20 Nov 2007

It looks like the ServiceDescription key may be deprecated in Leopard (10.5.x). With it in, the job doesn't run. In the log, the error says, "Unknown key: ServiceDescription."

-- DavidWolfe - 15 May 2008

I cannot get mailnotify to run without permissions errors unless it is run as root. I found changing the ownership the .plist file to root and loading the .plist with sudo launchctl load /Library/LaunchDaemons/com.twiki.mailnotify.plist will allow mailnotify to run, but ownership of cache.db in twiki/working/work_areas/LdapContrib is set to system and the TWiki stops working. It report that the cache.db file is inaccessible. Setting the ownership of that file back to _www fixes it, but it will eventually revert back to system and have to be reset again.

In my mind, there should be (and likely IS) a way to run the launchd .plist as the _www user, avoiding this whole mess. But I can't find any documentation of how to do that. If I simply change the owner of the file to _www, when launchd tries to load it, it fails, reporting "dubious ownership" on the file.

The .plist specs allow for a UserName and GroupName keys to be set within the .plist file, but when I set them, the launchd job fails anyway, and the log entry says that the UserName/GroupName key was ignored.

-- DavidWolfe - 15 May 2008

Please use the Support forum if you have questions about TWiki features. This comment section is about the documentation of this topic.
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2008-05-16 - DavidWolfe
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.