-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor_bot.sh
More file actions
29 lines (22 loc) · 821 Bytes
/
monitor_bot.sh
File metadata and controls
29 lines (22 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# Name of the tmux session
SESSION="mysession"
# Command to check if the script is running
SCRIPT_NAME="lichess-bot.py"
# Log file
LOG_FILE="bot_offline.txt"
echo "$(date): Checking status..." >> $LOG_FILE
# Check if the tmux session exists
if tmux has-session -t $SESSION 2>/dev/null; then
# Check if the script is running inside the tmux session
if ! pgrep -f "$SCRIPT_NAME" > /dev/null; then
# If the script is not running, restart it
tmux send-keys -t $SESSION "python3 lichess-bot.py -v" Enter
# Log the offline status and restart event
echo "$(date): Bot was offline and restarted." >> $LOG_FILE
else
# If the script is running, log that it is online
echo "$(date): Bot is online." >> $LOG_FILE
fi
fi
tmux clear-history -t $SESSION