A method for installed playback systems. Set as a login item for macOS. Adjust the target process and launch file as necessary. The watcher script will check that the defined process exists. If not, it will relaunch the target file. Based on the work of Jim Bell for Generativity by Fernanda D’Agostino, Suyama Space, Seattle WA, 2016.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
#!/bin/bash # @file: processWatcherTemplate.sh # @author: Brendan Hogan # @version: 1.0 # @update: 2021-09-02 # @Description: # This script watches a defined process(es) in macOS to make certain # that the process(es) exist (are running), for installation pieces. # The watcher loop runs every 10 seconds, and if the process(es) do not exist, # the script will re-open the target file(s) and continue the watcher loop. # This script is designed to launch at login and monitor while the host machine # is active. # # Make this script executable with 'chmod u+x' #------------------------------------------------------------------------------- # # RUN MAIN SCRIPT # Set the Terminal window size to 24 x 80: printf "\e[8;24;80;t" # Print some information to the terminal explaining how this works: clear sleep 1 echo "-------------------------------------------------------------------------" echo " <Your Application Process Here> WATCHER " echo " Launch and monitor target file(s) and verify that the target file(s) " echo " and/or applications exist(s) every 10 seconds. " echo " Restart the file(s)/applications as necessary. " echo " ------------------------------------------------------------------------" echo "" sleep 2 echo " ------------------------------------------------------------------------" echo " Waiting for 10 seconds. Allowing other boot processes to complete. " echo "-------------------------------------------------------------------------" sleep 10 echo "" echo "-------------------------------------------------------------------------" echo " Launching target file(s) and beginning watcher loop. " echo " Waiting 10 seconds before launching first file/process and " echo " beginning its watcher loop. " echo "-------------------------------------------------------------------------" echo "" sleep 10 # Define target file path as appropriate. # Launch the primary patch first: echo " Launching the <process> file and beginning its watcher loop. " # /usr/bin/open /add/your/target/file/pathway/here.extension # file pathway must match on line 63 # Run until the exists state is not true: until [ 0 = 1 ] # Begin <primary process> watcher loop: do /usr/bin/killall -0 <process> #Identify application by process name. if [ $? = 0 ] then echo "<process> is active. Checking again in 10 seconds... " else echo "" echo "" echo "$(date): Error: Process not found - restarting <process> file. " echo "" echo "" /usr/bin/open /add/your/target/file/pathway/here.extension fi sleep 10 done && sleep 10 # # Launch the secondary process next. echo " Launching the <process> file and beginning its watcher loop. " /usr/bin/open /add/your/target/file/pathway/here.extension # file pathway must match on line 87. # Run until the exists state is not true: until [ 0 = 1 ] # Begin <secondary process> watcher loop: do /usr/bin/killall -0 <process> #Identify application by process name. if [ $? = 0 ] then echo "<process> is active. Checking again in 10 seconds... " else echo "" echo "" echo "$(date): Error: Process not found - restarting <process> file. " echo "" echo "" /usr/bin/open /add/your/target/file/pathway/here.extension fi sleep 10 done |