创建脚本添加作者、文件名、版本、日期、描述内容,检查语法是否正确,并实现版本控制自动添加版本号。打开非自定义脚本文件时备份后打开;
#!/bin/bashlocal_ip="192.168.0.25" #过滤本地IPsecure_file=/var/log/securehosts_deny=/etc/hosts.denyhosts_secure=/etc/hosts.securesecure () { grep "Failed password for root from" $secure
如果没安装md5sum工具yum install isomd5sum检查文件是否被串改#!/bin/bashcheck_dir="/boot /etc /usr"for i in $check_dir do find $i -type f -exec md5sum {} \; |sort > /server/md5$i.new
#!/bin/bashsrc=/server/system_backup/dst=/backup () {rsync -av --exclude={"/proc","/sys","/run","/server"} $dst $src}recovery () {rsync -av --delete --exclude={"/proc","/sys","/run","/server"} $src $d
#!/bin/bashsrc=/root/server/ic/dst=/var/server_data/ic/dateTime=`date +%Y%m%d-%H:%M`mount -t cifs -o username=everyone,password="" //192.168.1.2/bak $srcBackup () { newFile=`ls -At $src |
备份MBR、根分区、Boot分区#!/bin/bashBak_dir=/mnt #已挂载的移动硬盘或其他外设Mbr=`fdisk -l |grep "Disk" |awk NR==1'{print $2}' |awk -F"/" '{print $3}'|sed s/://g`Root=`df |awk '/\//{print $1}' |awk NR==1'{print $1}'`
计算脚本执行时间: #!/bin/bash UseTime () { startTime=`date +%Y%m%d-%H:%M` startTime_s=`date +%s` $Command &n
Copyright © 2005-2024 51CTO.COM 版权所有 京ICP证060544号