I'm having trouble getting a simple backup script to run. The following script runs most of the time, but occasionally it fails entirely (without printing out any log information). Is there something in the script that could intermittently prevent it from running?
Even when it does run, the test log messages are sometimes delayed in appearing (as if the log file is not touched when it is written to, or the write to the log file is delayed), making diagnosis difficult.
#!/bin/bash printf "`date`: Start of Runkit backup Power Manager script:\n" >> ~/Library/Logs/Mine/tests.log if [ $(mount | grep -c '/Volumes/Run Kit') != 1 ] then printf "\tDon't copy: /Volumes/Run Kit not mounted\n" >> ~/Library/Logs/Mine/tests.log else if [ $(pmset -g ac | grep -c 'Wattage') != 1 ] then printf "\tDon't copy: Not plugged in\n" >> ~/Library/Logs/Mine/tests.log else caffeinate -s -t 1200 & printf "\tDo copy: /Volumes/Run Kit mounted\n" >> ~/Library/Logs/Mine/tests.log /Users/Rax/Library/Application\ Support/SuperDuper\!/Scheduled\ Copies/SDUtil -i || open file:///Users/Rax/Library/Application\%20Support/SuperDuper\%21/Scheduled\%20Copies/Smart\%20Update\%20Run\%20Kit\%20from\%20Main.sdsp/Copy\%20Job.app fi fi printf "`date`: End of Runkit backup Power Manager script:\n" >> ~/Library/Logs/Mine/tests.log exit 0