tmutil script runs in terminal but doesn't work in a cron job
I've got a korn shell script that issues either one of the following
sudo tmutil enable
sudo tmutil disable
I've updated sudoers.d so that these commands can be issued by my userid without a password.
If I issue the above commands in terminal, they work without password and I can see the Time Machine
Prefrences "Back up Automatically" turn off (when disable) and on (when enable). If I run my wrapper script from terminal, it also works (and additionally logs to a file and checks exit codes and logs any errout from the commands).
Running in cron, I can see from the logs that cron is in fact running the script at the specified times.
The disable command runs without error - but it doesn't change the state of Time Machine. The enable command gets exit code 80 and sends errout indicating I need to add the Terminal app to set of apps with Full Disk Access. I have done that. No change to the results.
I'm running my Time Machine to a NAS box and I want to replicate that data to the cloud. I'm trying to stop/start time machine each day so I can copy that data on the NAS to the cloud while it's not changing. I'd like to schedule this as an automated script that runs each night. The fact that Time Machine's backup start times drift (seems like it backs up every 62 minutes) doesn't help. Perhaps there is some other way to accomplish what I'm trying to do, but if I could figure out how to fix why the cron jobs are failing I think I've got a solution.
Any ideas on how to fix my cron ?
Mac Studio, macOS 12.6