Last active
August 18, 2017 19:24
-
-
Save Dineshs91/2d34c58da8e88671edc41d138bfa8474 to your computer and use it in GitHub Desktop.
Add cron job to the provided machines
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
#! /bin/bash | |
# Usage: | |
# sh add_cron.sh [key_file] [user] ip | |
key_file=$1 | |
username=$2 | |
ip=$3 | |
if [ $# -le 2 ]; then | |
echo "Usage: sh add_cron.sh [key_file] [user] ip" | |
exit 1; | |
fi | |
ssh -i "$key_file" "$username"@"$ip" "(crontab -l 2>/dev/null; echo '00 00 * * * docker container prune -f && docker image prune -f &> /var/log/cleanup.log') | crontab -" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add a cron job to remove docker unused images and containers.