I had this working before. But the system got hosed by a power surge, and like a damn idiot, I didn’t have a backup. Some of what I had was recoverable, and so the shell script and the plist are exactly as they were before, but not working.
I have a shell script, sweep.sh, that sweeps files in specified directories, with a specified extension, into a pair of external SSDs:
#!/bin/bash
cd /Users/mercury
cp *.savf /Volumes/BACKUP/mercury
mv *.savf /Volumes/BACKUP2/mercury
cd /Users/venus
cp *.savf /Volumes/BACKUP/venus
mv *.savf /Volumes/BACKUP2/venus
exit 0
When I call this script from the command line, it works fine.
But I have a launch daemon with the following plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>sweep</string>
<key>Program</key>
<string>/Users/europa/sweep.sh</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
</dict>
</plist>
It’s been tripped twice (and launchctl print system/sweep confirms that it’s there, and says “runs = 2” and “last exit code = 0”), but nothing actually happened!
Morning of September 9th: I added
<key>StandardOutPath</key>
<string>/Users/europa/sweep.out.txt</string>
<key>StandardErrorPath</key>
<string>/Users/europa/sweep.err.txt</string>
to the outer of the plist, and added some echo statements to the shell script, did a bootout, a bootstrap, and a kickstart, and I got this:
$ cat sweep.out.txt
mercury
venus
done
$ cat sweep.err.txt
cp: /Volumes/BACKUP/mercury/MERCURY.08xSep2025.savf: Operation not permitted
mv: fastcopy: open() failed (to): /Volumes/BACKUP2/mercury/MERCURY.08xSep2025.savf: Operation not permitted
cp: *.savf: No such file or directory
mv: rename *.savf to /Volumes/BACKUP2/venus/*.savf: No such file or directory
So even though it’s running (theoretically) under root authority, it’s not being allowed to access the external drives! So even though the OS is a couple of revisions back from Mojave, it appears that Mr. Davisson is on the right track.
