我正在我的 Ubuntu 10.04 LTS 服务器上从根 cron 运行组合备份脚本。
根 cron 如下所示:
# m h dom mon dow command
0 1 * * 2-6 /home/cbhiadmin/archive
它按预期执行。归档命令启动几个单独的设施备份。代码如下:
#!/bin/bash
# This script executes several individual facility archive processes & logs success.
/home/cbhiadmin/archive104
/home/cbhiadmin/archive106
if [ $? -ne 0 ]; then
echo "$(date '+%m/%d/%y-%H:%M') Nightly Addon backup SUCCESSFUL" >> /home/cbhiadmin/addon_backups/addon_backup.log
exit
fi
然后最后一部分是单独的设施备份,如下所示:
#!/bin/bash
# This script archives a facility, FTPs the archive to 10.5.2.76, & logs failure.
today=$(date '+%m%d%y')
site="106"
cd /home/cbhiadmin/addon_backups/"$site"
if [ ! -f "$site"adata_"$today".tar.gz ]; then
tar --exclude *.CSV --exclude *.csv -czf "$site"adata_"$today".tar.gz -C /usr/bbx/aon/ "$site"/ADATA/
if [ $? -ne 0 ];then
echo "$(date '+%m/%d/%y-%H:%M') $site: Nightly Addon backup FAILED" >> /home/cbhiadmin/addon_backups/addon_backup.log
fi
fi
cp "$site"adata_"$today".tar.gz /home/cbhiadmin/SAN/"$site"
find ~/SAN/"$site"/*.tar.gz -maxdepth 1 -mtime +60 -exec rm {} +
我的问题是最后一行似乎不适用于根 cron,但是当我自己以根用户身份运行存档时有效。
少了什么东西?