By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,847 Members | 1,274 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,847 IT Pros & Developers. It's quick & easy.

Help with a Cron Job Getting an error

P: 3
We have a Perl script that is supposed to back up all our files, folders and databases on our server however its sending an error via email. This is the error

Unrecognized character \xA6 at /home/onehosts/cronjob/backup.pl line 45.

This is the script
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2.  
  3. #### CONFIG #### 
  4. $BackupHour = 3; # TIME TO RUN THE BACKUP 
  5.  
  6. $BackupPath = "/home/onehosts/cronjob/"; #This is the folder where your backup file set file is stored 
  7. $BackupFileName = "backup.tar.gz"; #The name you want to give to your tar file 
  8. $BackupFileList = "file_list.txt"; #The list that you use to determine what parts to back up 
  9.  
  10. $HostHasMySQL = 1; # 1 = YES, 0 = NO 
  11. $MySQLRootPassword = 'jo5765'; 
  12. $MySQLBackupFileList = "mysql_list.txt"; #The list that you use to determine which databases to backup. 
  13. ################ 
  14.  
  15. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); 
  16.  
  17. if ($hour == $BackupHour) { 
  18. if ($HostHasMySQL == 1) { 
  19. &DumpDatabases; 
  20. &BackupFiles; 
  21.  
  22. #### SUBS #### 
  23.  
  24. sub BackupFiles 
  25.  
  26. # remove old backup file 
  27. $systemresult = system("rm $BackupPath\/$BackupFileName"); 
  28.  
  29. # create .tar.gz file 
  30. $systemresult = system("tar czvf $BackupPath\/$BackupFileName -T $BackupPath\/$BackupFileList \&>\/dev\/null"); 
  31.  
  32.  
  33. sub DumpDatabases 
  34.  
  35. my $name;
  36.  
  37. if (open(DBLIST, "$BackupPath\/$MySQLBackupFileList")) { 
  38.  
  39. while (<DBLIST>) { 
  40. if (/^\s*\#/  /^\s*$/) { 
  41. # Ignore Comments and Blank Lines 
  42. } elsif ( /^\s*([\w]+)\s*/ ) { 
  43. $name = $1; 
  44.  
  45. $systemresult = system("mysqldump --opt --user=onehosts_thirsty --password=$MySQLRootPassword $name > $BackupPath$ 
  46.  
  47.  
  48. close (DBLIST); 
  49.  
  50.  
  51.  
Thanks for the help!
Feb 20 '08 #1
Share this Question
Share on Google+
5 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Have you run this by hand to see if it works? If so, did it kick back any errors to you?
Feb 20 '08 #2

P: 58
On line 45, change to ||.
Feb 20 '08 #3

P: 3
Thank you for the quick response!

After making the changes that you suggested we are now getting this error.

Can't find string terminator '"' anywhere before EOF at /home/onehosts/cronjob/backup.pl line 50.

Thank you for your help!
Feb 22 '08 #4

P: 3
We did a search on Google for the error and made suggested changes and now we are getting this error.

Final $ should be \$ or $name at /home/onehosts/cronjob/backup.pl line 50, within string
syntax error at /home/onehosts/cronjob/backup.pl line 50, near "system("mysqldump --opt --user=onehosts_thirsty --password=$MySQLRootPassword $name > $BackupPath$""
Execution of /home/onehosts/cronjob/backup.pl aborted due to compilation errors.

Thank you for your help!
Feb 22 '08 #5

P: 58
On line 50, remove the last $ and replace it with ");
Feb 22 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.