Untitled

From Baby Ostrich, 4 Years ago, written in Bash, viewed 855 times.
URL https://p.gaa.st/view/042a84a8 Embed
Download Paste or View Raw
  1. #!/bin/sh
  2. ASPID=$(pidof airspy_adsb)
  3. if [ -z "${ASPID}" ]; then
  4.         exit 0
  5. fi
  6. # Connect for up to 3 seconds and expect to receive at least 5 lines. You can
  7. # update these numbers to different thresholds.
  8. if ! timeout 3 sh -c "nc localhost 33333 | head -5" > /dev/null; then
  9.         ASPID=$(pidof airspy_adsb)
  10.         if grep -qE 'VmPeak.*[0-9]{7}' /proc/${ASPID}/status; then
  11.                 # At the time it was I think leaking memory address space (I
  12.                 # *think* not that much actual memory?) and at some point
  13.                 # get stuck when hitting the Pi's limits so a restart would be
  14.                 # enough to revive.
  15.                 kill -9 ${ASPID}
  16.         else
  17.                 # If the memory state looks fine though, just reboot.
  18.                 /sbin/shutdown -r +2
  19.         fi
  20. fi
  21.  

Reply to "Untitled"

Here you can reply to the paste above