Skip to content

Instantly share code, notes, and snippets.

@phuysmans
Created December 2, 2019 14:49
Show Gist options
  • Save phuysmans/22bd0b9a667e40db6e255174e2eadf99 to your computer and use it in GitHub Desktop.
Save phuysmans/22bd0b9a667e40db6e255174e2eadf99 to your computer and use it in GitHub Desktop.
#!/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