Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Any ideas how to resolve the error that shows up in the Mac OSX system.log file? Or even what the error means?

I have the following cron job that runs every minute:

* * * * * cd /Library/[...]/report/ && nice -n 15 /usr/local/php5/bin/php -f report_generator.php > /dev/null 2>&1

Searches around the internet mentioning commenting out the cron job, but in my cause I can't do this. Most of Google's search results also don't have conclusive mention of what the error actually means.

The full error is:

Jul  2 14:50:00 xserve2 com.apple.launchd[1] (0x10c3f0.cron[46328]): Could not setup Mach task special port 9: (os/kern) no access

Mac OSX 10.5

share|improve this question
    
Mac OS X 10.5 or 10.4? –  Chealion Jul 3 '09 at 5:29

3 Answers 3

up vote 2 down vote accepted

I'm aware this won't quite fix the original issue but hopefully will tell us if the issue is a bug in launchd or something else.

Have you tried removing the cron job and re-instituting it as a proper launchd job instead? launchd is supposed to run the cron jobs but it sounds like you may be running into a bug.

You can create a launchd job using a GUI such as Lingon if you'd prefer instead of making the .plist yourself.

Sample .plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>test.dood.123</string>
	<key>ProgramArguments</key>
	<array>
		<string>cd</string>
		<string>/Library/REMOVED/DIRS/report/</string>
		<string>&amp;&amp;</string>
		<string>nice</string>
		<string>-n</string>
		<string>15</string>
		<string>/usr/local/php5/bin/php</string>
		<string>-f</string>
		<string>report_generator.php</string>
		<string>&gt;</string>
		<string>/dev/null</string>
		<string>2&gt;&amp;1</string>
	</array>
	<key>StartInterval</key>
	<integer>60</integer>
</dict>
</plist>

From my Googling it sounds like it's a bug in launchd running cron jobs. Source: 1

StartInterval will simply run it that many seconds from when the job was last run. StartCalendarInterval will allow you to run it at set times and instead of the <key>StartInterval</key> in the sample above use the following:

Run only at 3:15 AM

 <key>StartCalendarInterval</key>
 <dict>  
     <key>Hour</key>
     <integer>3</integer>
     <key>Minute</key>
     <integer>15</integer>
</dict>

Run every 5 minutes - StartCalendarInterval with an array. (I don't know of a better way to write this out so I'd love someone to elaborate on this)

 <key>StartCalendarInterval</key>
 <array>
     <dict>
         <key>Minute</key>
         <integer>0</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>5</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>10</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>15</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>20</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>25</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>30</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>35</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>40</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>45</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>50</integer>
     </dict>
     <dict>
         <key>Minute</key>
         <integer>55</integer>
     </dict>
 </array>

For more check out the Migrating from cron section on the documentation for launchd and man page

share|improve this answer
    
In the mean time I have converted the cron into launchd jobs and I'm not getting the same error. Although launchd has some really nice features, it's missing the ability to run at the 0s of each minute. I need this because I have 2 scripts that need to alternate running every 60s. Right now I have to start them 60s apart to get the 60s difference. Cron does this really nicely with 1,3,5... and 2,4,6... in the minute "field". –  Darryl Hein Jul 3 '09 at 16:37
    
Sorry, I've edited my question to show how to use StartCalendarInterval which does allow you to schedule a specific time for it to run. –  Chealion Jul 4 '09 at 17:27

The entry in the system log seems to be made by the launchd application itself, with the (child) sub-process of the cron job in brackets. The entry is not tied to any particular cron job, but happens on every occasion that any cron job runs: I have jobs that run once a day and a job that runs every 5 minutes, with log entries (Could not setup Mach task special port 9: (os/kern) no access) on each and every occasion. The problem must be part of the procedure of running a cron job (external to that cron job) and is probably to be found in one of the lib files that are part of the cron process, such as '/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation', for example. The problem is unlikely to be part of launchd, as it only occurs when cron is invoked.

Convoluted though it may be, the best way to stop the log entries, while permitting the jobs to run, is to cut out the middle-man - cron - and run the job direct from launchd. Examples of how to achieve that are numerous (see above for a start)!

share|improve this answer
    
We did try launchd, but found that it comes with one very annoying issue: the job when scheduled using StartInterval would run at every say 5 minutes from the time you started. So, you start at 3:30, it runs at 8:30, 13:30, etc. (Cron would run at 0,5,10...) This isn't a big deal, but we have 2 scripts that need to alternate with each other, so one running 0,2,4,6,8... and the other running 1,3,5,7,9... What you end up doing is starting the processes very exactly. –  Darryl Hein Oct 9 '09 at 7:16
    
The other issue is that we couldn't find an reasonable way to have the launchd plist added automatically immediately after restart; we had to do it manually. Both of these things are issues that cron solved many years ago and now launchd is trying to replace, but just isn't there yet. –  Darryl Hein Oct 9 '09 at 7:17

Darryl,

Without knowing what that script does (or who's crontab it is), I'd suggest that you first try to run it from the command line as that user.

Offhand, it appears that it's a permissions thing. Can you provide more information?

More searching revealed two forum threads on the subject:

http://discussions.apple.com/thread.jspa?threadID=1224189&start=0&tstart=0

http://discussions.apple.com/thread.jspa?messageID=5666826&#5666826

Hope that helps!

share|improve this answer
    
The script doesn't cause the same error when run at the command line (outside of cron). The cron is running under root. What other info could be helpful? –  Darryl Hein Jul 2 '09 at 21:20
    
BTW, I just tried running the cron under a different user and I still get the same error. –  Darryl Hein Jul 2 '09 at 21:23
    
@k3ri those are 2 links that come up in Google. As I said, I searched and neither of those links actually provide any solution other than removing the crons. –  Darryl Hein Jul 2 '09 at 21:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.