macOS Catalina: execute bash script on boot with launchctl Before updating to Catalina (10.15.1) my agent based on a bash script was working perfectly.

I had set the agent in order to execute the bash script on boot. 
Here is the plist file:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;mark.battery.info&lt;/string&gt;
        &lt;key&gt;Program&lt;/key&gt;
        &lt;string&gt;/Users/mark/Dropbox/Exec/BatteryInfoOnBoot.sh&lt;/string&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;true/&gt;
    &lt;/dict&gt;
&lt;/plist&gt;


After the last update I noticed that the script (BatteryInfoOnBoot.sh) was no longer loaded at boot and if I execute the command:

launchctl list | grep mark
-   1   mark.battery.info


I read that the status 1 means:


  PID - Status 1 means that the process doesn't have enough privileges
  to access some files


ref

The script BatteryInfoOnBoot is very simple:

#!/bin/bash

echo "~~~~~~~~~"  &gt;&gt; /Users/mark/Documents/battery-log.txt
date  &gt;&gt; /Users/mark/Documents/battery-log.txt
/Users/mark/Dropbox/Exec/BatteryInfo.sh &gt;&gt; /Users/mark/Documents/battery-log.txt


instead BatteryInfo.sh is used only to get some useful info:

#!/bin/bash

echo "Current battery percentage:"
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
echo ""

echo "Cycle count:"
system_profiler SPPowerDataType | grep "Cycle Count"
echo ""

echo "Capacity stats:"
ioreg -brc AppleSmartBattery | grep -i capacity | grep -v Legacy | grep -v BatteryData | grep -v AppleRaw
echo ""


PS: the script is still working if I exec it manually:

/Users/mark/Dropbox/Exec/BatteryInfoOnBoot.sh


Any suggestions?
/Users/mark/Documents/ is a protected user folder (as Downloads and Desktop).

Usually you can add applications to System Preferences > Security &amp; 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 BatteryInfoOnBoot.sh to /Users/mark/Library/Logs/ and it will work.

Proof (Virtual machine - no battery inside ;-)):

user@host ~ % 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/ or /Library/Logs/) you can keep your original file as it is but you have to add /bin/launchctl to System Preferences > Security &amp; Privacy > Privacy > Full Disk Access then.

Proof (still no battery inside):

user@host ~ % cat Documents/battery-log.txt 
~~~~~~~~~
Tue Dec  3 01:32:30 CET 2019
Current battery percentage:

Cycle count:

Capacity stats: