Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Buadhai

macrumors 65816
Original poster
Jan 15, 2018
1,115
434
Korat, Thailand
I have an old 2010 MBA which runs High Sierra. It is located at a condo which I visit for a few days each month. The machine runs 24/7 mostly to upload webcam photos to a host every four minutes, to assemble and upload a time-lapse video every 24 hours and to perform routine maintenance tasks. Here is the webcam page: Cha Am Cam

All of this is done with bash shell scripts that are run via launchd with the help of Lingon.

When I arrived last week I discovered that the USB camera had failed because the housekeeper who had cleaned the place just before our arrival had crushed the USB cable when she locked the balcony door. I ordered a new cable which took a few days to arrive from Bangkok.

After I received the new USB cable, the images produces by the webcam were highly variable. Some were 100% black and others were 100% white. Others were horribly washed out. Sometimes the binary which grabs the images, imagesnap, would become non-responsive. I tried to fix the latter problem using timeout. That seemed to work. Oddly, as time passed, the images produced by the camera steadily improved. No more all-black or all-white images. The exposure on the useable images also normalized. After a day, everything was back to normal. Can a digital camera heal itself? (Rhetorical question.)

One morning, after observing a string of successful image grabs and uploads, I hopped on my bicycle and went out for coffee. When I got back I was shocked to see that about a half hour after I left the uploads stopped. In fact, the machine had stopped grabbing images at all. A little checking revealed that launchd was refusing to run the image capture and upload script with error 78 - Function Not Implemented. How helpful. Odd, because the script ran fine from the command line.

I figured that some change that I made to the script must have caused this. But, if so, how did it continue to run for half an hour or so after I'd left for coffee? I poured over the script and could find nothing obvious. I happened to have a backup of all scripts that I made last December. I copied the backup script to the MBA and it started to run right away.

I made the same edits to the backup script as I had made to the original. The script continued to run with no problems. Mystery.
The next morning I checked to see if the video upload worked. It did not. Same launchd error: 78 - Function Not Implemented. Now, this is a script that has run, unchanged, as it is, once a day for several years. Almost never fails and when I does it's always due to a network error.

So, I copied the absolutely identical backup and, voila, it ran just fine. Mystery.

I decided to check some other scripts. I found about six that also started failing to run at the same time as the image capture and upload script. These are all simple scripts that run regularly and have done so, without change, for years. Why did they all suddenly stop and all about the same time all due to the same launchd error? Why were other scripts not affected?

I copied over the backups of all the failing scripts and they all ran with no problems.

I'd love to have an explanation as to how this happened and what I can do to prevent it from happening again.
 

Buadhai

macrumors 65816
Original poster
Jan 15, 2018
1,115
434
Korat, Thailand
I had seen that, but those examples are mainly from people who were unable to get a script to run from launchd the first time around. In my case, all the scripts had been running fine, some for years, when they suddenly stopped nearly simultaneously. The craziest thing is that the scripts started running again when replace by an identical backup. The system log files were of no help at all.
 

thecosmicfrog

macrumors newbie
Jan 19, 2021
1
0
Thought I'd register here as I managed to fix the same issue that @Buadhai was having - launchd jobs failing after a recent macOS update.

For me, it was because I had the process being executed (a JAR file) by my .plist file in a user's Desktop directory. While pulling my hair out troubleshooting, I remembered that macOS has recently gotten strict about processes' access to certain directories, including Desktop. I moved the executable file into a directory under the user's home directory. So now it resides in /Users/<the_user>/<some_directory>/my-executable.jar, and I updated my plist file to point there instead.

tl;dr - make sure your executable file isn't in what macOS now considers a restricted folder, i.e. Desktop

Hope that helps at least one person!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.