The "sweep" daemon job that I developed in Is there an easy way to automatically schedule a move of files matching a certain pattern from a user directory to a USB drive? and What went wrong with my launchd plist? seems to be working just fine. The last time it actually had files to transfer to the external drives was yesterday morning; this morning, it had no actual work to do, so I don't know whether it ran or not.
This morning, I created another launchd plist ("backlocal," which backs up a couple of rarely-changed Samba shares every six months), and I did a launchd load
on it just now, followed by a launchd list
, to verify that it was loaded.
"backlocal" was indeed in the launchd list
, but "sweep" was not (I immediately did a launchd load
to manually reload it).
I don't know whether it ran this morning or not. All I do know is that if I bring up the console, and search "all messages" for "sweep," I get:
5/20/23 8:00:09.787 AM com.apple.xpc.launchd[1]: (sweep[3314]) Service exited with abnormal code: 1
5/21/23 8:00:05.558 AM com.apple.xpc.launchd[1]: (sweep[3573]) Service exited with abnormal code: 1
5/22/23 8:00:05.744 AM com.apple.xpc.launchd[1]: (sweep[3828]) Service exited with abnormal code: 1
5/23/23 8:00:15.388 AM com.apple.xpc.launchd[1]: (sweep[590]) Service exited with abnormal code: 1
I took a look at a couple of threads that came up automatically when I entered the above log messages, What does "Service exited with abnormal code: 1" mean? and launchd notification on abnormal exit but I'm not sure if they have any bearing here.
Could these messages have something to do with my not seeing "sweep" in launchd load
? I will note that "sweep" did successfully sweep a file to the external backup drives on the 23rd. I will also note that the most recent reboot was about Noon on Monday.
As of this moment, "sweep.plist" looks like:
<?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>8</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
(but I'm about to add StandardOutPath and StandardErrorPath tags, as suggested by launchd.info), and sweep.sh looks like:
#!/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
launchd
ran your script, but it failed and then exited. This could be for any number of reasons. To find out why, we need to see the script and ideally, you want to do some error trapping in your scripts to generate your own error codes so you know what failed and when.exit 0
and see if that fixes it.launchctl
as a regular user (i.e. not root), many options (includingload
,unload
, andlist
) interact with the list of that user's launch agents. To interact with the list of launch daemons, you need to runlaunchctl
as root (e.g. withsudo launchctl ...
).