Apple - macOS Catalina: execute bash script on boot with launchctl
/Users/mark/Documents/ is a protected user folder (as Downloads and Desktop).
Usually you can add applications to System Preferences > Security & Privacy > Privacy > Full Disk Access to enable access to these folders. Terminal is already added probably - the reason why no error is shown executing the script manually.
Change the destination of the log file in the shell script
/Users/mark/Library/Logs/ and it will work.
Proof (Virtual machine - no battery inside ;-)):
[email protected] ~ % cat Library/Logs/battery-log.txt ~~~~~~~~~ Tue Dec 3 01:23:55 CET 2019 Current battery percentage: Cycle count: Capacity stats:
As an unwanted alternative (because even a-typical log files belong to
/Library/Logs/) you can keep your original file as it is but you have to add
/bin/launchctl to System Preferences > Security & Privacy > Privacy > Full Disk Access then.
Proof (still no battery inside):
[email protected] ~ % cat Documents/battery-log.txt ~~~~~~~~~ Tue Dec 3 01:32:30 CET 2019 Current battery percentage: Cycle count: Capacity stats: