欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

备份所有网站的 crontab 文件 cron 有大用 有大大用

下面是cron文件里的内容  每有的1号15号的2点20分执行这个cron

20 2 1,15 * * /bin/bash /www/wdlinux/wdcp/shell/sitebackup_my.sh

下面是cron执行的bash文件 sitebackup_my.sh



#!/bin/bash

#print the directory and file


for file in /home/wwwroot/*

do

if [ -d "$file" ]

then

#   echo "tar zcPvf /home/backup/site${file##*/}-`date  '+%Y-%m-%d'`.tar.gz" $file

  tar zcPvf "/home/backup/site/${file##*/}-`date  '+%Y-%m-%d'`.tar.gz" $file

fi

done

~


普通分类: