![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
documenting problem and solution all in one place.
all of a sudden i'm getting this once per hour in my system log:
luckily it wasn't hard to figure out where this came from, since i just set up a cron job yesterday (to hourly back up my chrome bookmarks so i could import them into "launchbar", because there is no elegant way to get them there).
this is the crontab entry:
that shell file is correct, and the cron job executes successfully; it does what it is supposed to do. but it leaves this message behind.
no googled discussions had an immediate solution (other than removing the cron job -- no; i want this to happen, this job has to run), or to write some code to suppress the message from going to the log (uh, no thanks for bad bandaid solutions). this looks to be a bug in leopard's cron or launchd or the kernel itself which never got fixed.
syslog just marks this as a warning. but for the last 2 days i've also come to my desk in the morning only to find my mac frozen, with that message as the last entry in the syslog. coincidence? maybe not. something clearly happens when this cron job runs. so what exactly is failing?
"task special port 9" seems to be a kernel thing.
huh. cron is just a symbolic link:
a bit more research shows that apple has basically replaced cron (and init.d, /etc/rc, xinetd, .profile; anything having to do with running scripts at startup, login, or certain date and time intervals) with launchd, which becomes the root system process to launch everything else. i normally hate when they fuck with unix, since one reason why i like the mac is that i can just dive underneath the GUI and use unix commands to run things when needed. but launchd seems to me actually a good idea.
since there is no way to get cron running without causing this error and possibly freezing my system after it's happened >15 times, i guess that means i need to learn how to rewrite a cron job for launchd. and hey, it'd be more "leopardly".
when launchd starts up, it looks for files in /System/Library/LaunchAgents and /System/Library/LaunchDaemons (and in ~/Library for user-specific instructions). the files end in .plist (which are property list files, in XML or binaries of XML commands). *gah*. ok, i need an editor for this. but this explains a bunch of non-system stuff running even though i cannot see and turn it off in startup/login items. which means i can turn some of that stuff off. yay. i am thinking that the whole startup item stuff goes against the idea of "one process to launch them all" and should also be converted -- why have several different places from which processes might be launched; that's just confusing.
and joy; open source comes through again. here's lingon, a launchd configuration file editor.
that makes the creation of this new job ever so much easier; no need to learn XML -- but since the program has an expert mode, one can see the generated XML. this is the finished code:
tested, and work perfectly. now my chrome bookmarks are getting exported once every hour (3600 seconds) and converted to launchbar requirements (that's what ChromeExportBookmarks.sh does).
i don't really like having to hardcode the path to my home directory, but launchd does not require a shell, so i can't just use ~.
lingon is incredibly easy to use; i didn't even read any instructions before putting this together.
i'm feeling accomplished now. :)
all of a sudden i'm getting this once per hour in my system log:
10/12/17 3:00:00 AM com.apple.launchd[1] (0x10f050.cron[29922]) Could not setup Mach task special port 9: (os/kern) no access
luckily it wasn't hard to figure out where this came from, since i just set up a cron job yesterday (to hourly back up my chrome bookmarks so i could import them into "launchbar", because there is no elegant way to get them there).
this is the crontab entry:
0 * * * * /Users/account/ChromeExportBookmarks.sh > /dev/null 2>&1
that shell file is correct, and the cron job executes successfully; it does what it is supposed to do. but it leaves this message behind.
no googled discussions had an immediate solution (other than removing the cron job -- no; i want this to happen, this job has to run), or to write some code to suppress the message from going to the log (uh, no thanks for bad bandaid solutions). this looks to be a bug in leopard's cron or launchd or the kernel itself which never got fixed.
syslog just marks this as a warning. but for the last 2 days i've also come to my desk in the morning only to find my mac frozen, with that message as the last entry in the syslog. coincidence? maybe not. something clearly happens when this cron job runs. so what exactly is failing?
"task special port 9" seems to be a kernel thing.
huh. cron is just a symbolic link:
lrwxr-xr-x 1 root wheel 12 4 Mar 2009 /usr/lib/cron -> ../../var/at
a bit more research shows that apple has basically replaced cron (and init.d, /etc/rc, xinetd, .profile; anything having to do with running scripts at startup, login, or certain date and time intervals) with launchd, which becomes the root system process to launch everything else. i normally hate when they fuck with unix, since one reason why i like the mac is that i can just dive underneath the GUI and use unix commands to run things when needed. but launchd seems to me actually a good idea.
since there is no way to get cron running without causing this error and possibly freezing my system after it's happened >15 times, i guess that means i need to learn how to rewrite a cron job for launchd. and hey, it'd be more "leopardly".
when launchd starts up, it looks for files in /System/Library/LaunchAgents and /System/Library/LaunchDaemons (and in ~/Library for user-specific instructions). the files end in .plist (which are property list files, in XML or binaries of XML commands). *gah*. ok, i need an editor for this. but this explains a bunch of non-system stuff running even though i cannot see and turn it off in startup/login items. which means i can turn some of that stuff off. yay. i am thinking that the whole startup item stuff goes against the idea of "one process to launch them all" and should also be converted -- why have several different places from which processes might be launched; that's just confusing.
and joy; open source comes through again. here's lingon, a launchd configuration file editor.
that makes the creation of this new job ever so much easier; no need to learn XML -- but since the program has an expert mode, one can see the generated XML. this is the finished code:
?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>account.ChromeExportBookmarks.Launchd</string> <key>LowPriorityIO</key> <true/> <key>ProgramArguments</key> <array> <string>/bin/sh</string> <string>/Users/account/ChromeExportBookmarks.sh</string> </array> <key>ServiceDescription</key> <string>backup chrome bookmarks for launchbar</string> <key>StandardOutPath</key> <string>/dev/null</string> <key>StartInterval</key> <integer>3600</integer> <key>WorkingDirectory</key> <string>/Users/account</string></dict></plist>
tested, and work perfectly. now my chrome bookmarks are getting exported once every hour (3600 seconds) and converted to launchbar requirements (that's what ChromeExportBookmarks.sh does).
i don't really like having to hardcode the path to my home directory, but launchd does not require a shell, so i can't just use ~.
lingon is incredibly easy to use; i didn't even read any instructions before putting this together.
i'm feeling accomplished now. :)