记录日常常用的linux脚本命令
docker下mysql备份脚本
#!/bin/bash
backupdir=/home/data/mysql/mysql_backup
time=` date +%Y_%m_%d_%H_%M_%S `
db_name=alisql
db_user=root
db_pass=GC5vJwHL@Q
docker exec $db_name /usr/local/mysql/bin/mysqldump --all-databases -u $db_user -p$db_pass | gzip > $backupdir/$time.sql.gz
find $backupdir -name "*.sql.gz" -type f -mtime +10 -exec rm -rf {} \; > /dev/null 2>&1
linux部署jar脚本
NAME=api-server-1.0-SNAPSHOT.jar
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
echo "prepare to deploy $NAME after 3s..."
sleep 3s
nohup java -Xmx1024m -jar /root/$NAME > /root/api.log 2>&1 &
echo excute success from deploy-api.sh
tail -f api.log
注意:本文归作者所有,未经作者允许,不得转载