第一个里程碑   测试命令 把文件/etc/services压缩到/tmp

[root@oldboyedu-39 ~]# cd / && tar zcf /tmp/etc.tar.gzetc/services

[root@oldboyedu-39 /]# ls -l /tmp/

total 404

  w-r--r--. 1 root root 127314Aug  9 18:16 etc.tar.gz

 

 

[root@oldboyedu-39 /]# cd / && tar zcf /tmp/etc-$(date+%F_%H).tar.gz etc/services

[root@oldboyedu-39 /]# ls -lrt /tmp/

total 532

-rw-------. 1 root root    439Aug  9 11:42 crontab.iCpuPc

-rw-r--r--. 1 root root 127314 Aug 9 18:16 etc.tar.gz

-rw-r--r--. 1 root root127314 Aug  9 18:18etc-2017-08-09_18.tar.gz

 

vim/server/scripts/etc-bak.sh

cd / && tar zcf /tmp/etc-$(date +%F_%H).tar.gz etc/services

 

 

[root@oldboyedu-39 /]# /bin/sh /server/scripts/etc-bak.sh

[root@oldboyedu-39 /]# /bin/sh /server/scripts/etc-bak.sh>/dev/null 2>&1

 

[root@oldboyedu-39 /]# ls -lrt /tmp/

total 532

-rw-r--r--. 1 root root 127314 Aug  9 18:23 etc-2017-08-09_18.tar.gz

[root@oldboyedu-39 /]# ls -lrt /tmp/

total 532

-rw-r--r--. 1 root root 127314 Aug  9 18:24 etc-2017-08-09_18.tar.gz


#bak /etc/serves

00 */2 * * * /bin/sh /server/scripts/etc-bak.sh >/dev/null2>&1