Created
August 6, 2016 08:25
-
-
Save joergeschmann/a1b03b3db35b86d59de50bd18ad8640e to your computer and use it in GitHub Desktop.
Copy distributed log files into a folder
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
baseFolder="/tmp/app" | |
logFilesToCopy=("$baseFolder/auth/log/auth.log" "$baseFolder/jobs/log/jobs.log" "$baseFolder/app.log") | |
destination="/tmp/logs" | |
for logFile in ${logFilesToCopy[@]} | |
do | |
# logFile -> variable; ## -> greedy front trim; */ -> match everything until the last '/' | |
filename=${logFile##*/} | |
currentFile="$destination/$filename" | |
if [ -f "$currentFile" ] | |
then | |
rm "$currentFile" | |
fi | |
cp -f "$logFile" "$destination" | |
chmod 644 "$currentFile" | |
done | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment