Skip to content

Instantly share code, notes, and snippets.

@gwpl
Created December 10, 2018 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwpl/22b3c3e66711489b8d36cf8e5923c308 to your computer and use it in GitHub Desktop.
Save gwpl/22b3c3e66711489b8d36cf8e5923c308 to your computer and use it in GitHub Desktop.
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