launchd/launchctl Error 78 when scheduling a BASH script on an external drive

I've had no luck in resolving this error that is set when it was scheduled to run. The BASH script and logs point to an external drive. I've seen notes of permissions but have no idea if I need to somehow set 'launchd' to run on all disks.


I have one launchd service, which successfully runs daily, but only references the main system disk.


Here's my plist. I really don't feel like spending the money on 3rd party launchcontrol to have it tell me what's wrong (if it can)


<?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>com.keeper_backup.app</string>

<key>Program</key>
<string>/Volumes/Keeper/keeper_backup.sh</string>

<key>StandardOutPath</key>
<string>/Volumes/Keeper/keeper_backup.stdout</string>

<key>StandardErrorPath</key>
<string>/Volumes/Keeper/keeper_backup.stderr</string>

<key>WorkingDirectory</key>
<string>/Volumes/Keeper</string>

<key>StartCalendarInterval</key>
<dict>
<key>Weekday</key>
<integer>1</integer>
<key>Hour</key>
<integer>20</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>



Any suggestions appreciated.




[Re-Titled by Moderator]

Mac mini, macOS 15.3

Posted on Feb 11, 2025 05:16 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 13, 2025 05:46 AM

You can take a much simpler approach than launchd and that is to use the macOS Automator app. you can easily use it to "wrap" any type of task and have it run on a scheduled basis.


It does support adding shell scripts as well as actual applications.


You can start here with basic framework on how to create a scheduled task:

Create scheduled automator tasks


While I have not personally done any scheduling tasks, I have created Automator "apps" that wrap shell scripts with additional Automator functions which is nice because you can just place the "app" icon any where convenient and just a double click to start it.


you can check out Apple's page on general usage here to set it up the actual script "wrapper":

Automator User Guide for Mac - Apple Support

Be sure to click the blue table of contents link to go through it.

Similar questions

12 replies
Question marked as Top-ranking reply

Feb 13, 2025 05:46 AM in response to DS256

You can take a much simpler approach than launchd and that is to use the macOS Automator app. you can easily use it to "wrap" any type of task and have it run on a scheduled basis.


It does support adding shell scripts as well as actual applications.


You can start here with basic framework on how to create a scheduled task:

Create scheduled automator tasks


While I have not personally done any scheduling tasks, I have created Automator "apps" that wrap shell scripts with additional Automator functions which is nice because you can just place the "app" icon any where convenient and just a double click to start it.


you can check out Apple's page on general usage here to set it up the actual script "wrapper":

Automator User Guide for Mac - Apple Support

Be sure to click the blue table of contents link to go through it.

Feb 11, 2025 01:13 PM in response to DS256

Backup is not and should not be that complicated and I would scrap that whole idea.


I would get a new external drive or grab one that I could format correctly for macOS.

Erase and reformat a storage device in Disk Utility on Mac - Apple Support


Then I would use macOS Time Machine which is free or the paid version or CarbonCopyClone.

Back up your Mac with Time Machine - Apple Support

https://bombich.com/


Feb 12, 2025 04:54 AM in response to Zurarczurx

Zurarczurx wrote:

Thinking out loud (i.e. don't know if it can be done) - could you create a saved search in Finder that looks for the rating and then backs up the images in this folder?


Thanks for the suggestion. I a) Didn't know you could save searches or b) add addition qualifiers.


I discovered that there is a 'Rating' in the search but it did not seem to find any of the photos where I have an assignment.



I checked More Info but there was no place to assign a Rating. From Google, I found instructions to use COMMAND+# to assign a rating but I was not able to get that working nor could I find where the rating is stored. A test and dump of the metadata for a photo did not show any Rating information.


My logic is the following. It is designed to reduce the binary introspection of metadata in the photos


  1. Read all .XMP files looking for a rating of 1 or more. When found save the YYYYMMDD-HHMMSS to a list
  2. Read all photos (RAW files, JPG, TIF, DNG etc). If the file name matches one in the list, skip. If not get the rating and if greater than 1 save the YYYYMMMDD-HHMMSS in the list.
  3. Using the list, create a BASH script with 'cp -p /path/YYYYMMMDD-HHMMSS* /keeper' (-p is important). Execute the script.
  4. Start Cloudberry to sync /Keeper to AWS S3.


So, interesting exercise but doesn't help me get any closer to fixing the error 78 problem.

Feb 11, 2025 11:50 AM in response to den.thed

@den.tred what the keeper_backup.sh is not relevant unless you tell me launchd introspects the BASH script.


It runs fine stand-alone. It has multiple steps related with a Python selection of candidates, local copies, and cloud transfers.


Neither keeper_backup.stdout or keeper_backup.stderr are created from launchd.


Now, what you did get me to the check was the permissions of the service that does run against this was that doesn't


heliotype:Keeper paul1$ ls -hl keeper_backup.sh
-rwx------@ 1 paul1  staff   1.0K 11 Feb 08:07 keeper_backup.sh

heliotype:Keeper paul1$ ls -hl ~/Scripts/daily/photo_backup.sh
-rwxr-xr-x@ 1 paul1  staff   2.4K  8 Feb 08:01 /Users/paul1/Scripts/daily_photo_backup.sh


Now I find I can't give READ or EXECUTION to everyone. The /Volumes/Keeper only has me as having access but I can't find how to open that point up. When I access 'Get Info' for the Volume or any find, all I see is my permission but I can't change anything. If it matters, the volume is exFAT.


Here is what I've tried on the file but I suspect it is not working because it doesn't align with the permissions on the volume. I also cannot use the following at the Volumes level even under SUDO.


heliotype:Keeper paul1$ chmod -v -v 0755 keeper_backup.sh
keeper_backup.sh: 0100700 [-rwx------ ] -> 0100755 [-rwxr-xr-x ]
heliotype:Keeper paul1$ ls -hl keeper_backup.sh
  -rwx------@ 1 paul1  staff   1.0K 11 Feb 08:07 keeper_backup.sh

So, looking for help in trying to set permissions.

Feb 11, 2025 01:43 PM in response to den.thed

den.thed wrote:

Backup is not and should not be that complicated and I would scrap that whole idea.


@den.thed I appreciate your are trying to help by saying I have the wrong solution so here's my backup challenge. Sometimes a fresh look can find a completely different approach.


I want to backup my 'keeper' photos. 'Keepers' are those photos which have a rating of 1 or more. Depending on photo type, the rating value will either be stored in the photo file itself or an associated XMP side car file. The rating is not exposed hence the need for the Python program to introspect files to find them. When I find one I want to back up all related files to processing. They are all prefixed YYYYMMDD-HHMMSS.*.


If you have any ideas of how to apply your approach to my problem and backup the results to AWS S3 I'm all ears.


And I am also using Timemachine and RSYNC to provide backups onsite plus MSP360 Cloudberry Backup for MAC for backups to AWS S3.



Feb 12, 2025 03:43 AM in response to den.thed

den.thed wrote:

To make and keep things simple, I would copy the "Keepers" to a Folder and then periodically backup that Folder to one or two of those other locations.

That's what keepers_backup.sh does.


The problem I'm having is that the launchd service definition throws an error 78 and does not run. What idea's do you have on the issue?

Feb 12, 2025 05:19 AM in response to DS256

Sorry - can't answer your Bash qn.


I didn't realize you were using XMP. My image management app writes all metadata direct to the jpg so it's searchable using Spotlight and other search tools (including when synched to iPhone). I just rated one of my pics 1* to see what happens. It comes up in the images IPTC metadata as "starrating" but isn't searchable by Finder so it wouldn't be any good.


I don't use ratings but if I wanted to do what you're doing I'd use my IM app to add a unique keyword like "zzOneStar" to the description field of all the pics with rating 1 (this would be trivial for existing images and I'd add it to my workflow for new images) and then create a Finder search for "zzOneStar" and add the search folder

to the scheduled backup.



Feb 12, 2025 08:54 AM in response to DS256

As I noted in a previous post, I was not able to set the keeper_backup.sh with the permissions for others to READ or EXECUTE it. This was also true for the /Volumes/Keepers volume. I've discovered that exFAT volumes do not support permissions or ownership.


I copied the keeper_backup.sh to ~/Scripts (a directory I created for LAUNCHD work) and changed the references in the PLIST from /keeper to /Scripts.


<?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>com.keeper2_backup.app</string>
        
        <key>Program</key>
			<string>/Users/paul1/Scripts/keeper_backup.sh</string>
			
		<key>StandardOutPath</key>
			<string>/Users/paul1/Scripts/keeper_backup.stdout</string>
			
		<key>StandardErrorPath</key>
			<string>/Users/paul1/Scripts/keeper_backup.stderr</string>
			
		<key>WorkingDirectory</key>
			<string>/Users/paul1/Scripts</string>
        
		<key>StartCalendarInterval</key>
			<dict>
				<key>Weekday</key>
					<integer>1</integer>
				<key>Hour</key>
					<integer>20</integer>
				<key>Minute</key>
					<integer>0</integer>
			</dict>
    </dict>
</plist>



As an additional safety check, I unloaded the previous definition and created a version two of the service. I loaded it and was able to get it to run with


launchctl kickstart gui/`id -u`/com.keeper2_backup.app


So, with all of the LAUNCHD references pointing to where the system has WRITE access, the services is working. I have some errors in pathnames which I need to clean up but at least is running


Hope this helps others who come later.

Feb 13, 2025 06:02 AM in response to woodmeister50

woodmeister50 wrote:

You can take a much simpler approach than launchd and that is to use the macOS Automator app. you can easily use it to "wrap" any type of task and have it run on a scheduled basis.

OMG! Thank you! I had no idea AUTOMATOR existed.


I found LAUNCD looking for a replacement for SYSTEMD that I use on my Linux systems. Shows I should cast a broader net when looking for how to do things on MACos which I'm new too.


I'm taking a breather after battling the LAUNCHD and exFAT (no ownership/permissions) issues, I've not resolved, and will try to simplify using AUTOMATOR.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

launchd/launchctl Error 78 when scheduling a BASH script on an external drive

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.