2025-02-28 16:00:16 +08:00

26 lines
503 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
KEYWORD="3mc31t"
# 目标服务器信息格式IP地址:端口)
SERVERS=(
"172.26.1.3:22"
"172.26.1.7:22"
"172.26.1.9:22"
"172.26.1.15:22"
)
# 目标路径
LOG_DIR="/data/logs/advisor"
for SERVER in "${SERVERS[@]}"; do
# 获取 IP 和端口
IP=$(echo $SERVER | cut -d ':' -f 1)
PORT=$(echo $SERVER | cut -d ':' -f 2)
# 查询日期
echo "log on $IP:"
ssh -p $PORT ubuntu@$IP "grep -n $KEYWORD $LOG_DIR/*.log"
done
echo "All logs printed."