cronjob 创建 tar 文件但无法上传

cronjob 创建 tar 文件但无法上传

我正在尝试使用以下组合来安排备份脚本cronjob:'tar,并使用 htar 实用程序上传到 HPSS。我已在 crontab 中为脚本中所需的所有命令设置绝对路径,但是脚本仍然失败。我收到的错误示例如下。我从脚本中得到的退出代码是 72,即关键操作系统文件丢失。我知道该文件存在于指定目录中。

如果我从终端运行脚本(没有 cronjob),它就可以正常工作。

如何使脚本与 cronjob 一起工作?

crontab 文件如下所示:

PATH=/root/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/usr/local/sbin
* * * * * /bin/sh /home/user/backup/script.sh

我收到的错误如下所示:

Beginning backup of the server
Beginning htar...
INFO: I/O error occurred, and error -2 trying to stat file upload.tar
INFO: Retrying after I/O error at archive file offset 0
INFO: I/O error occurred, and error -2 trying to stat file upload.tar
INFO: Retrying after I/O error at archive file offset 0
INFO: I/O error occurred, and error -2 trying to stat file upload.tar
INFO: Retrying after I/O error at archive file offset 0
INFO: I/O error occurred, and error -2 trying to stat file upload.tar
INFO: Retrying after I/O error at archive file offset 0
72

我正在运行的脚本片段如下所示

#!/bin/bash 
log=path_to_log_file
home_source=path_to_home
backup_source=path_to_backup

echo "Beginning backup of server" >> $log
sudo /usr/bin/tar -cf $backup_source/home.tar.gz $home_source

echo "Beginning htar..." >> $log
/usr/local/bin/htar -cvf "upload.tar" $backup_source/'home.tar.gz' >> $log

RETVAL=$?

echo $RETVAL >> $log

相关内容