I dont know If anyone Had the Problem of the scraper crashing when the sleep time is Set top a faster pace. Did it so it might have a slight time Advantage dir the announcement. The Script startet to Crash every 2h or so. So i came Up with the Idea of keeping the sleeptime to a Minimum and simply restarting it hourly via bash Script. Create a Folder in Home called Scripts New File called restart-script.sh and Insert the following (between the Linea) exactly
!/bin/bash
echo "###########" date
SCRIPT_DIRECTORY="/home/pi/gateio-crypto-trading-bot-binance-announcements-new-coins" SCRIPT_NAME="main.py" WAIT_SECONDS=3 # don't change anything below this line function start_script() {
OLD_WD=$PWD
"$SCRIPT_DIRECTORY"
echo "starting $SCRIPT_NAME in the background" python3.9 "$SCRIPT_NAME" &
cd "$PWD" }
SCRIPT_PID=$(pgrep -f "$SCRIPT_NAME") if [ -n "${SCRIPT_PID}" ]; then echo "$SCRIPT_NAME running - killing it " pkill -f "$SCRIPT_NAME" else echo "$SCRIPT_NAME not running" start_script
Then open a cronjob: cronjob -e
>>.Log logs If It die indeed kill and restart, #2>1& gives you additional Data in Case of
I dont know If anyone Had the Problem of the scraper crashing when the sleep time is Set top a faster pace. Did it so it might have a slight time Advantage dir the announcement. The Script startet to Crash every 2h or so. So i came Up with the Idea of keeping the sleeptime to a Minimum and simply restarting it hourly via bash Script. Create a Folder in Home called Scripts New File called restart-script.sh and Insert the following (between the Linea) exactly
!/bin/bash
echo "###########" date
SCRIPT_DIRECTORY="/home/pi/gateio-crypto-trading-bot-binance-announcements-new-coins" SCRIPT_NAME="main.py" WAIT_SECONDS=3 # don't change anything below this line function start_script() {
OLD_WD=$PWD
"$SCRIPT_DIRECTORY" echo "starting $SCRIPT_NAME in the background" python3.9 "$SCRIPT_NAME" &
cd "$PWD" }
SCRIPT_PID=$(pgrep -f "$SCRIPT_NAME") if [ -n "${SCRIPT_PID}" ]; then echo "$SCRIPT_NAME running - killing it " pkill -f "$SCRIPT_NAME" else echo "$SCRIPT_NAME not running" start_script
Then open a cronjob: cronjob -e
>>.Log logs If It die indeed kill and restart, #2>1& gives you additional Data in Case of
error
0 /bin/bash /home/pi/scripts/restart-script.sh >> scripts/restart.log 2>1&