You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

2 years ago
#!/usr/bin/with-contenv bash
echo "Starting Script...."
2 years ago
processstartid="$(ps -A -o pid,cmd|grep "/config/extended/scripts/start.sh" | grep -v grep | head -n 1 | awk '{print $1}')"
2 years ago
echo "To kill script, use the following command:"
echo "kill -9 $processstartid"
for (( ; ; )); do
let i++
2 years ago
if [ ! -d "/config/logs" ]; then
mkdir -p "/config/logs"
chmod 777 "/config/logs"
chown abc:abc "/config/logs"
2 years ago
fi
2 years ago
bash /config/extended/scripts/download.sh 2>&1 | tee "/config/logs/extended_script_run_${i}_$(date +"%Y_%m_%d_%I_%M_%p").txt" > /proc/1/fd/1 2>/proc/1/fd/2
if [ -f "/config/logs/log-cleanup" ]; then
rm "/config/logs/log-cleanup"
2 years ago
fi
2 years ago
touch -d "8 hours ago" "/config/logs/log-cleanup"
2 years ago
if find "/config/logs" -type f -iname "extended_script_run_*.txt" -not -newer "/config/logs/log-cleanup" | read; then
2 years ago
find "/config/logs" -type f -iname "*.log" -not -newer "/config/logs/log-cleanup" -delete
2 years ago
fi
2 years ago
if [ -f "/config/logs/log-cleanup" ]; then
rm "/config/logs/log-cleanup"
2 years ago
fi
if [ -z "$scriptInterval" ]; then
scriptInterval="15m"
fi
2 years ago
echo "Script sleeping for $scriptInterval..."
2 years ago
sleep $scriptInterval
done
exit 0