I back up critical files on my wife's Mac every morning at 2am. I have a cron job that
starts at 2am and I have the system wake up at 1:55 to be ready for it. I updated her
system to 10.11 two weeks ago and the backups stopped working. I noticed that cron
is "deprecated", and I presume that the update effectively stopped it from working.
(Happy to know otherwise if I'm wrong ... but certainly something happened to cron.)
I'm unable to get the launchctl approach to work. Details below. Desperate for
help to get the .plist file to start up.
So I started to prototype how to do the same thing as cron with launchctl by scheduling a
small task on my own Mac. The task is to start a shell script "mailjob" to send
me an email message every minute. The script works fine when invoked with
"bin/mailjob".
I want her backup to run under her uid. So in my prototyping, I want the .plist
file to be in ~/Library/LaunchAgents/ . File listed below. I've checked it
for syntactical correctness, and I modeled it after a working com.adobe .plist file,
so I think it's correct.
The problem is that I can't get the task to load and/or start with launchctl. The
added commands and nomenclature associated with the 10.11 update didn't help ...
they're very unclear, and there aren't any tutorials. So I've tried both the
newer "bootstrap" command approach and the older "load"/"start" command approach,
but I cant' get either one to work.
Could someone who knows something about this system please look this over and
tell me what I'm doing wrong? I'm sure it's a trivial misunderstanding of
the launchctl command syntax, but after hours of working on it, I haven't
figured it out.
So, given the "~/bin/mailjob" shell script I want to execute every minute,
and given the .plist file listed below,
1) Start with this (mailjob not listed):
HDT:~ hdtodd$ launchctl list | grep mail
- 0 com.apple.mdworker.mail
HDT:~ hdtodd$
2) Try "bootstrap" but it doesn't load anything:
HDT:~ hdtodd$ launchctl bootstrap user/502/com.examples.mailjob ~/Library/LaunchAgents/com.examples.mailjob.plist
HDT:~ hdtodd$ launchctl list | grep mail
- 0 com.apple.mdworker.mail
HDT:~ hdtodd$
3) Try "load" and "start"; it loads mailjob but nothing starts:
HDT:~ hdtodd$ launchctl load ~/Library/LaunchAgents/com.examples.mailjob.plist
HDT:~ hdtodd$ launchctl list | grep mail
- 0 com.examples.mailjob
- 0 com.apple.mdworker.mail
HDT:~ hdtodd$ launchctl start com.examples.mailjob
HDT:~ hdtodd$ launchctl list | grep mail
- 0 com.examples.mailjob
- 0 com.apple.mdworker.mail
HDT:~ hdtodd$ mail
No mail for hdtodd
HDT:~ hdtodd$
BUT ... I do get this message from "syslog -w":
Feb 19 12:22:18 HDT com.apple.xpc.launchd[1] (com.examples.mailjob) <Notice>: Service only ran for 6 seconds. Pushing\
respawn out by 4 seconds.
How do I get launchctl to actually schedule and start the task pointed to by the .plist file?