Created
December 2, 2019 14:49
-
-
Save phuysmans/22bd0b9a667e40db6e255174e2eadf99 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
#!/usr/bin/env bash | |
set -eo pipefail | |
CONTAINER=$1 | |
NOW=$(date +%s) | |
if [ "$(docker ps -a -q -f name=${CONTAINER})" ]; then | |
STARTED_AT=$(docker inspect -f "{{.State.StartedAt}}" ${CONTAINER}) | |
STARTED=$(date -d "${STARTED_AT}" +%s) | |
DIFF=$(( (${NOW} - ${STARTED}) / 60)) | |
echo ${DIFF} | |
else | |
echo 0 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment