env-docker/bin/get_logs.sh
Chad 8602f7ada2
Fix Directory Hardcodes, Documentation Improvements (#10)
* Improve the main crontab example.

* Remove /opt/Docker hardcodes.

* Add periods.

* Improve readability.

* Begin removing hardcoded path from the bin files.

* Update main README to no longer enforce hardcoded path. Other improvements.

* Add the load folder with a README.

* Add load folder and its README.

* Improve reverse proxy text files.

* Switch to tabs.

* Update all scripts for tabs, DOCKER_HOME, and comments.

* Let users know the directory choice is optional.

* Fix environment file.

* Add more details for the reverse proxy load balancing.

* Don't actually listen for postgres.

* Fix comments on source file.

* Be more explicit on the pathing.
2023-07-23 14:51:48 -07:00

34 lines
616 B
Bash
Executable File

#!/bin/bash
# 2022-08-05 Hyperling
# Put active logs into files for analysis.
# usage: get_logs.sh
## Setup ##
DIR="`dirname $0`"
PROG=`basename $0`
if [[ $DIR == *"."* ]]; then
DIR="`pwd`"
fi
if [[ -z $DOCKER_HOME ]]; then
DOCKER_HOME="$DIR/.."
fi
dir=logs
date_format="+%Y%m%d-%H%M%S"
## Main ##
cd $DOCKER_HOME
mkdir -p $dir
docker ps | while read container_id image_name other; do
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
done
chmod -R 755 $dir
exit 0