crontab -l 查看后台定时任务
crontab -e 编辑定时任务
*/10 * * * * nohup /home/sqlbackup/sqlbackup.sh >> /home/sqlbackup/out.log 2>&1 &
同步其他服务器(142.411.121.457)数据 sh脚本
#!/bin/bash
currentpath=/home/backup/moke
zipbackuptime=30
backpath="moke"
ippath="http://142.411.121.457:8086"
zippasswd="34os3BurJ5eXq6yhH2N3ABCDEF"
function makedir(){
echo $(date "+%Y-%m-%d %H:%M:%S")
if [ -d $currentpath/$(date +%y%m%d) ]; then
echo "$(date +%y%m%d) is exsit"
else
mkdir $currentpath/$(date +%y%m%d)
echo "$(date +%y%m%d) is building"
fi
}
function backupsql(){
bakckpath=$currentpath/$(date +%y%m%d)
backuptime=$(date +%y%m%d%H%M)
timenum=${backuptime:0:8}
cd $bakckpath
downloadAddress=$timenum$zipbackuptime$backpath.zip
echo $downloadAddress
downpath=$ippath/$(date +%y%m%d)/$downloadAddress
wget $downpath .
}
makedir
backupsql
本服务器nginx
server {
listen 8086;
server_name localhost;
location / {
root /home/zip;
autoindex on;
index index.html;
}
access_log /home/ubuntu/logs/zip.log.log;
error_log /home/ubuntu/logs/zip.errorlog.log;
}