Last active
August 18, 2017 19:24
-
-
Save Dineshs91/2d34c58da8e88671edc41d138bfa8474 to your computer and use it in GitHub Desktop.
Revisions
-
Dineshs91 revised this gist
Aug 18, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,8 @@ # Usage: # sh add_cron.sh [key_file] [user] ip key_file=$1 username=$2 ip=$3 if [ $# -le 2 ]; then -
Dineshs91 revised this gist
Aug 18, 2017 . 1 changed file with 7 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,15 @@ #! /bin/bash # Usage: # sh add_cron.sh [key_file] [user] ip username=$2 key_file=$1 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 -" -
Dineshs91 created this gist
Aug 18, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #! /bin/bash # Usage: # sh add_cron.sh [key_file] [user] [ip1, ip2, ...] username=$1 key_file=$2 if [ $# -le 4 ]; then echo "Usage: sh add_cron.sh [key_file] [user] [ip1, ip2, ...]" exit 1; fi total_ips=$# for ip in `seq 3..$total_ips` do echo 'ssh -i "${key_file}" "${username}"@"${ip}"' done ssh -i key_file username@ip