Created
March 7, 2018 10:57
-
-
Save csghone/44bc0dfda110ec06c422b34aa693ae13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
| cd $(dirname "$0") | |
| # Date 16:05 hours ago | |
| DATE=$(date -d '965 minutes ago' +'%Y-%m-%d') | |
| PID_FILE="grep_platform_logs.pids" | |
| FILE_PATTERN="platform.2018-03-06.log$" | |
| SEARCH_OPTS="-Ei "recovery"" | |
| PLATFORM_FILES=($(find /home/archival/cpp_archival/ | grep $FILE_PATTERN)) | |
| cat $PID_FILE | xargs -IX sh -c 'kill -9 -X' | |
| echo $BASHPID > $PID_FILE | |
| create_minimal_log() { | |
| NEW_LOG=$(echo $FILE | awk -F'/' '{print $(NF-1)"."$(NF)}') | |
| tail -F -n +1 $FILE | grep $SEARCH_OPTS > minimal.$NEW_LOG | |
| } | |
| for FILE in ${PLATFORM_FILES[@]} | |
| do | |
| create_minimal_log & | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment