LaunchAgent script - Operation not permitted

Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
I just noticed that my main LaunchAgent script last worked on January 29th. It runs at midnight and backs-up important stuff to OneDrive.
  • The script lives in /usr/local/bin
  • /bin/bash has full-disk access
  • The script runs fine when I run it standalone
  • It runs, but all of the commands within fail: Operation not permitted
HELP!

P.S. I'm running macOS Monterey v12.3
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,034
Reaction score
2,441
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
So when you run the script manually from the command line, it woks fine or does it give you the error? Can you share, generically, what some of the commands are so that I can see if they would run on my machine also running Monterey.
 
OP
John Greer
Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
It runs fine when I run it from Terminal.
It only does 3 different commands:
  • zip
  • rsync
  • cp
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,034
Reaction score
2,441
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
The files you are trying to zip/rsync and cp are in your home folder or folders owned by your account? If so, that's likely the culprit. When scripts are launched through LaunchAgent, they must use some other type of account or named account which wouldn't have access to your folders.

To change that, you can try to elevate the permissions of your script so that it will execute with admin privs to get around that. But ideally, you should see if there is a way of executing those scripts as you, so that you don't need any super access and less possibility of causing any harm.
 
OP
John Greer
Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
The files you are trying to zip/rsync and cp are in your home folder or folders owned by your account? If so, that's likely the culprit. When scripts are launched through LaunchAgent, they must use some other type of account or named account which wouldn't have access to your folders.

To change that, you can try to elevate the permissions of your script so that it will execute with admin privs to get around that. But ideally, you should see if there is a way of executing those scripts as you, so that you don't need any super access and less possibility of causing any harm.
Gotcha. I'll check into that. Curious why it would run for months, then stop on Jan 30th...
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,034
Reaction score
2,441
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Did you by any chance update your machine or something? If it was running previously, that's about the only thing I can think of.
 
OP
John Greer
Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
That's what I'm guessing, but nothing that I can recall.
I guess I'll go back to cron.
 
OP
John Greer
Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
I'm having trouble making cron work. Setup seems right, but nothing gets kicked-off...
 
OP
John Greer
Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
It turn out that for cron to work, the script had to be in my user/me/... folder.
I had it in /usr/local/bin for LaunchAgent. Computers! Am I right?
 
OP
John Greer
Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
I figured it out!

My script backs-up critical data to OneDrive. On the day it stopped working, I enabled a OneDrive feature called "Free Up Space." I did that to minimize my Time Machine backup size. I just read a blurb that said OneDrive on Mac began having trouble with this on, wait for it, Jan 30th.

Once I reversed that, and went back to "Always Keep on This Device," the script works again!
 
Joined
Jan 1, 2009
Messages
16,379
Reaction score
4,735
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Good you sorted it out, John. Be aware that OneDrive has recently also defaulted to removing material from the internal drive that is synced through OneDrive. Lots of complaints about that. I had to select each and every item on OneDrive and change it to keep it locally. I don't know if MS fixed it or not, but I don't use OD as much because of that.
 
OP
John Greer
Joined
Jun 20, 2011
Messages
70
Reaction score
0
Points
6
Good you sorted it out, John. Be aware that OneDrive has recently also defaulted to removing material from the internal drive that is synced through OneDrive. Lots of complaints about that. I had to select each and every item on OneDrive and change it to keep it locally. I don't know if MS fixed it or not, but I don't use OD as much because of that.
That’s exactly what I had to do! Harumph.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top