- 论坛徽章:
- 0
|
请教大家一个问题,为什么下面的perl脚本用./backup.pl运行正常,但是放到crontab底下就会报错呢?这个脚本是用来备份svn的。
perl脚本:
- #!/usr/bin/perl -w
- $svn_repos="/opt/svn-repos-test";
- $backups_dir="/home/youyan/svn-backup";
- $next_backup_file = "daily_incremental_backup.".`date +%Y%m%d_%H:%M`;
- open(IN,"$backups_dir/last_backed_up");
- $previous_youngest = <IN>;
- #chomp $previous_youngest;
- close IN;
- $youngest=`svnlook youngest $svn_repos`;
- chomp $youngest;
- if ($youngest eq $previous_youngest)
- {
- print "No new revisions to back up...\n";
- exit 0;
- }
- $first_rev = $previous_youngest + 1;
- $last_rev=$youngest;
- print "Backing up revisions $first_rev to $last_rev...\n";
- $svnadmin_cmd = "svnadmin dump --incremental ".
- "--revision $first_rev:$last_rev ".
- "$svn_repos>$backups_dir/$next_backup_file";
- `$svnadmin_cmd`;
- print "Compressing dump file...\n";
- print `gzip -9 $backups_dir/$next_backup_file`;
- open(LOG,">$backups_dir/last_backed_up"); #记录备份的版本号
- print LOG $last_rev;
- close LOG;
复制代码
报的错误:
Date: Fri, 10 Jul 2009 11:43:01 +0800
Message-Id: <200907100343.n6A3h155005897@localhost.localdomain>
From: root@localhost.localdomain (Cron Daemon)
To: root@localhost.localdomain
Subject: Cron <root@localhost> /home/youyan/svn-backup/daily-backup.pl
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: < ATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Use of uninitialized value in scalar chomp at /home/youyan/svn-backup/daily-backup.pl line 7.
Can't exec "svnlook": No such file or directory at /home/youyan/svn-backup/daily-backup.pl line 9.
Use of uninitialized value in scalar chomp at /home/youyan/svn-backup/daily-backup.pl line 10.
Use of uninitialized value in string eq at /home/youyan/svn-backup/daily-backup.pl line 11.
Use of uninitialized value in string eq at /home/youyan/svn-backup/daily-backup.pl line 11.
No new revisions to back up... |
|