Created
March 2, 2020 16:29
-
-
Save seunggabi/22ebcabef7133177f071cadeb556149b to your computer and use it in GitHub Desktop.
print_access_log.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# ./print_access_log.sh keyword 20200302 server_list.txt | |
### server_list.txt ### | |
a | |
b | |
c | |
####################### | |
keyword=$1 | |
file=/home1/irteam/logs/apache/access.log.$2 | |
servers=() | |
IFS=$'\n' | |
for line in `cat $3`; do | |
servers+=("$line") | |
done | |
for i in "${servers[@]}" | |
do | |
logs=$(/usr/local/bin/rsh -l irteam ${i} grep -r ${keyword} ${file}) | |
IFS='' read -r line <<< $logs | |
if [ line ] | |
then | |
echo "["$i"] "$line | |
else | |
echo "["$i"] empty" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment