The rsync cause of Linux operations Automation scripts
Because you want to do the synchronization log script, considering that the machine is more, the back also to expand.
Recently I was learning python (a comparative dish).
Ideas
Composition: Configuration file + Execute script
After the script executes, it reads the contents of each field in the configuration file and assigns values to the corresponding variables in the Execute command.
Configuration file Format:
password file path; user name; IP; module name; target location path
Code:
#!/bin/env python
Import Time,os,datetimewith Open (' config/auto_rsync.conf','R', encoding='Utf-8') asF:file_info=f.readlines () Count=0Count1=1 forFile_useinchFile_info:file_use.strip (" ") iffile_use[0] =="#"or file_use[0] =="\ n": Continue Else: File_line= File_use.split (";") Count+=1 whileCount1 <=Count:pass,user,ip,mod_name,ddir= file_line[0],file_line[1],file_line[2],file_line[3],file_line[4] #print (pass,user,ip,mod_name,ddir) nowtime= Datetime.datetime.now (). Strftime ('%y-%m-%d_%h:%m:%s') Os.system ("/usr/bin/nohup/usr/bin/rsync-avzp--password-file=%s%[email protected]%s::%s%s >>/var/log/rsync_%s.log "%(pass,user,ip,mod_name,ddir,nowtime)) Count1+=1Time.sleep (1)
Rsync for Linux operations Automation scripts