Last active
September 10, 2019 10:33
-
-
Save tronghuan98hd/ee25ce9418a2b1cb4c26e9b4eda95376 to your computer and use it in GitHub Desktop.
Bash script
This file contains 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 | |
#make some variables | |
datetime=`date +"%d%m%Y-%H%M%S"` | |
file="money-data-$datetime" | |
url_file="/root/mysql/logs" | |
ip_server="172.16.2.160" | |
des_direct="/var/money/logs/" | |
#Backup database Money into file | |
mkdir -p $url_file | |
mysqldump -u root -p Money > $url_file/$file | |
#send backup file to other server | |
scp $file root@$ip_server:$des_direct |
This file contains 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 | |
# get info operate system | |
a=`awk -F= ' NR==3 {print $2}' /etc/os-release` | |
b="ubuntu" | |
# install nginx | |
if [ $a == $b ]; then | |
sudo apt-get -y install nginx | |
else | |
sudo yum -y install epel-release | |
sudo yum -y install nginx | |
fi |
This file contains 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 | |
function help(){ | |
cat <<EOF | |
Usage: lg ip | |
Module distribution: | |
EOF | |
cat list.txt | |
} | |
if [ $# -ne 1 ]; | |
then | |
help; | |
exit 1; | |
fi | |
regex='^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' | |
if [[ $1 =~ $regex ]] | |
then | |
ssh-copy-id root@$1 | |
ssh root@$1 | |
else | |
ssh-copy-id root@172.16.2.$1 | |
ssh root@172.16.2.$1 | |
fi | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment