Skip to content

Instantly share code, notes, and snippets.

@calexandre
Last active March 4, 2019 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calexandre/d6523ccc7ca1ba03a34ab6518caa656f to your computer and use it in GitHub Desktop.
Save calexandre/d6523ccc7ca1ba03a34ab6518caa656f to your computer and use it in GitHub Desktop.
The following script executes a docker prune command and outputs the result to a log file. If the exit code is different from 0, it will output the result to stdout. This is very useful for crontabs since you'll only get alerted when the scripts write to the stdout.
(docker container prune -f --filter "until=24h" && docker volume prune -f && docker image prune -f -a --filter "until=24h") | ts "[%Y-%m-%d %H:%M:%S]" >> /var/log/docker-curator/docker-curator.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment