79706783

Date: 2025-07-18 21:59:03
Score: 0.5
Natty:
Report link

Couldn't get a single command to work on WSL no nodejs so edited this from @ntshetty

#!/bin/bash
# ./monitor.sh main.py &
# $1 passes the filename
# source: @ntshetty stackoverflow.com/a/50284224/3426192
python $1 &             # start
while true
do
    mdhash1=`find $1 -type f -exec md5sum {} \; | sort -k 2 | md5sum`
    sleep 5
    mdhash2=`find $1 -type f -exec md5sum {} \; | sort -k 2 | md5sum`
    if [ "$mdhash1" = "$mdhash2" ]; then
       echo "Identical"
    else
       echo "Change Detected Restarting Web Server"
       pkill -9 -f $1   # get PID to stop
       python $1 &      # restart
    fi
done
echo "Ended"
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: social