MastodonHelp/web/clitools/maintain/pcloop.bash

27 lines
774 B
Bash
Raw Normal View History

#!/bin/bash
trap "exit" INT
basedir=`dirname "$0"`
cd "$basedir/.."
resurrfp=".pcresurrectdone"
cmdlogfp="peerscrawl.log"
logfp="pcloop.log"
resdom=26
function log {
echo `date "+%Y-%m-%d %H:%M:%S.%N"` "${1}" >> "${logfp}"
}
while true; do
dom=$((`date "+%d"`+0))
[ $dom -lt $resdom -a -f "$resurrfp" ] && rm "$resurrfp"
if [[ ($dom -ge $resdom ) && !(-f "$resurrfp") ]]; then # usa un gracetime di 2 mesi
touch "$resurrfp"
log "### Eseguo peerscrawl.php con un gracetime di 2 mesi ###"
./peerscrawl.php -g 2M -e peerscrawl.exclude &> $cmdlogfp
else # use il gracetime di default
log "### Eseguo peerscrawl.php con il gracetime di default ###"
./peerscrawl.php -e peerscrawl.exclude &> $cmdlogfp
fi
tail $cmdlogfp >> $logfp
log "### Fine ###"
done
exit 0;