Post
Topic
Board Bitcoin Discussion
Re: How to repeat the same command automatically in Linux?
by
Bitsky
on 09/03/2018, 14:18:44 UTC
Instead of keeping a terminal open, send it to background and redirect the output into a logfile.

I would try something like this:
Code:
#!/usr/bin/bash

if [[ ! $(pgrep -f "rtgferfd.py") ]]; then
echo "Bot down"
python rtgferfd.py --solid --r --fr --quantity 35 --wait_time 34 > /var/log/rtgferfd.log 2>&1 &
fi

if [ "$(grep -c "LINE LINE LINE" /var/log/rtgferfd.log)" -gt "0" ]; then
echo "Bot died"
pkill -f "rtgferfd.py"
python rtgferfd.py --solid --r --fr --quantity 35 --wait_time 34 > /var/log/rtgferfd.log 2>&1 &
fi

But really, fix the bugs in the bot instead of trying to bandaid them with workarounds.