123

#!/bin/bash

# 设置参数和路径
SECRET_KEY="liberty carbon thing glass unlock crucial today report lemon arm orient miss deputy despair delay faint razor rural budget feature rebuild always dust gun"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

while true; do
  # 判断进程是否存在
  if pgrep -f "start\.sh" >/dev/null 2>&1; then
    echo "The script is running."
  else
    echo "The script is not running. Restarting in 5 minutes..."
    sleep 300  # 等待 5 分钟

    cd "$SCRIPT_DIR" && \
    nohup expect -c "
      spawn ./tower start
      expect \"Enter your oL mnemonic:\"
      send \"$SECRET_KEY\\n\"
      interact
    " >> /path/to/logfile.log 2>&1  &
  fi

  sleep 60  # 每隔 1 分钟检查一次进程状态
done

posted @ 2023-06-20 03:11  老王教你学Linux  阅读(20)  评论(0编辑  收藏  举报