1、每周一到周六的凌晨3点20分,运行cp命令对/etc/目录进行归档另存,存储位置

为/backups/etc-YYYY-MM-DD;

20 3 * * 1-6 /bin/cp -a /etc /backups/etc-`date +\%F`  

注意:这里的%要用\转义

2、每周日凌晨2点30分,运行cp命令对/etc/fstab文件进行备份,存储位置为/backup/fstab-

YYYY-MM-DD-hh-mm-ss

   30 2 * * 7 /bin/cp -a /etc/fstab /backup/fstab-`date +\%F-\%H-\%M-\%S`

3、每天晚上12点,取得/proc/meminfo文件中所有以S或M开头的行,追加

至/statistics/meminfo.txt文件中,且每天的消息之前,要加上类似===============分隔线;

  方法一:  

  * 12 * * * * /bin/echo "================" >> /statistics/meminfo.txt && /bin/egrep "^(S|

  M)" /proc/meminfo >> /statistics/meminfo.txt

  方法二:

  * 12 * * * * /bin/awk 'BEGIN{print "================="}/^[SM]/{print $0}' /proc/meminfo >> /statistics/meminfo.txt

  方法三:

  * 12 * * * * /bin/echo "================" >> /statistics/meminfo.txt && /bin/grep "^[SM]" /proc/meminfo >> /statistics/meminfo.txt

  方法四:

  * 12 * * * * /bin/awk 'BEGIN{print "================="}$0~/^[SM]/{print $0}' /proc/meminfo >> /statistics/meminfo.txt