[VMware][ESXi][crontab] 移除特定日期以前的目錄或映像檔資料
12 月 09
Alfresco, GNU/Linux, Shell scripts No Comments
#!/usr/bin/expect spawn ssh "root@ip-or-hostname" expect "*assword: " send -- "your-password\n" expect "\[root@ip-or-hostname:~\] " #send -- "hostname\n" #send -- "/bin/sh /vmfs/volumes/datastore1/ghettoVCB/bin/ghettoVCB.sh -g /vmfs/volumes/datastore1/ghettoVCB/backup.conf -m vmguest-name\n" send -- "echo \"Processing vmguest-name archives\"\n" send -- "cd /vmfs/volumes/vm-bak/vmguest-name\n" send -- "ls -t | grep -v `date -D %s +\"%Y-%m-%d\" -d \$((\$( date +%s) - 0 ))` | grep -v `date -D %s +\"%Y-%m-%d\" -d \$((\$( date +%s) -86400 ))` | grep -v `date -D %s +\"%Y-%m-%d\" -d \$((\$( date +%s) - 172800 ))` > list2del.txt\n" send -- "cat list2del.txt\n" send -- "rm -rf `cat list2del.txt`\n" send -- "rm -f list2del.txt\n" expect eof