Skip to content

Instantly share code, notes, and snippets.

@gwpl gwpl/watchdog.sh
Created Dec 10, 2018

Embed
What would you like to do?
Checks if amount of files in directory has changed, if not than it executes killall to let thing restart in a loop
#!/bin/bash
counterf=no_of_files_last_time.txt
tmpf="$(mktemp)"
counter_old="$(cat "$counterf")"
echo -n 'Missing: '
comm -23 <(sort -u sites_source.txt) <(ls -1|sort -u)|wc -l
echo -n 'Total: '
sort -u sites_source.txt|wc -l
echo -n 'Files: '
counter_new="$(find -type f |wc -l)"
echo ${counter_new} |tee "$tmpf"
df -h .
if cmp -s "$counterf" "$tmpf"; then
echo Counters SAME - Metric FAILED
echo Trying to reboot things
#killall -v loop_tumblr_crawler.sh
#killall -v tumblr-photo-video-ripper.py
killall -v python
date --iso-8601=seconds
else
echo Counters differ - Metric OK
cat "$tmpf" > "$counterf"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.