2022-08-06 07:52:11 -05:00
|
|
|
#!/bin/bash
|
|
|
|
# 2022-08-05 Hyperling
|
|
|
|
# Put active logs into files for analysis.
|
|
|
|
# usage: get_logs.sh
|
|
|
|
|
2023-07-23 14:51:48 -07:00
|
|
|
## Setup ##
|
|
|
|
|
|
|
|
DIR="`dirname $0`"
|
|
|
|
PROG=`basename $0`
|
|
|
|
if [[ $DIR == *"."* ]]; then
|
|
|
|
DIR="`pwd`"
|
|
|
|
fi
|
|
|
|
if [[ -z $DOCKER_HOME ]]; then
|
|
|
|
DOCKER_HOME="$DIR/.."
|
|
|
|
fi
|
2022-08-06 07:52:11 -05:00
|
|
|
|
|
|
|
dir=logs
|
|
|
|
date_format="+%Y%m%d-%H%M%S"
|
|
|
|
|
2023-07-23 14:51:48 -07:00
|
|
|
## Main ##
|
|
|
|
|
2022-08-06 07:52:11 -05:00
|
|
|
cd $DOCKER_HOME
|
|
|
|
mkdir -p $dir
|
|
|
|
docker ps | while read container_id image_name other; do
|
2023-07-23 14:51:48 -07:00
|
|
|
image_name=${image_name##*/}
|
|
|
|
echo $container_id $image_name
|
|
|
|
docker inspect $container_id 1>/dev/null 2>&1 &&
|
|
|
|
docker logs $container_id 1>${dir}/${image_name}.log.`date $date_format` 2>&1
|
2022-08-06 07:52:11 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
chmod -R 755 $dir
|
|
|
|
|
|
|
|
exit 0
|