Help with a Cron Job Getting an error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • overcomersonline
    New Member
    • Feb 2008
    • 3

    Help with a Cron Job Getting an error

    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
    [code=perl]
    #!/usr/bin/perl

    #### CONFIG ####
    $BackupHour = 3; # TIME TO RUN THE BACKUP

    $BackupPath = "/home/onehosts/cronjob/"; #This is the folder where your backup file set file is stored
    $BackupFileName = "backup.tar.gz" ; #The name you want to give to your tar file
    $BackupFileList = "file_list.txt" ; #The list that you use to determine what parts to back up

    $HostHasMySQL = 1; # 1 = YES, 0 = NO
    $MySQLRootPassw ord = 'jo5765';
    $MySQLBackupFil eList = "mysql_list.txt "; #The list that you use to determine which databases to backup.
    ############### #

    ($sec,$min,$hou r,$mday,$mon,$y ear,$wday,$yday ,$isdst) = localtime(time) ;

    if ($hour == $BackupHour) {
    if ($HostHasMySQL == 1) {
    &DumpDatabas es;
    }
    &BackupFiles ;
    }

    #### SUBS ####

    sub BackupFiles
    {

    # remove old backup file
    $systemresult = system("rm $BackupPath\/$BackupFileName ");

    # create .tar.gz file
    $systemresult = system("tar czvf $BackupPath\/$BackupFileName -T $BackupPath\/$BackupFileList \&>\/dev\/null");

    }

    sub DumpDatabases
    {

    my $name;

    if (open(DBLIST, "$BackupPat h\/$MySQLBackupFil eList")) {

    while (<DBLIST>) {
    if (/^\s*\#/ ¦¦ /^\s*$/) {
    # Ignore Comments and Blank Lines
    } elsif ( /^\s*([\w]+)\s*/ ) {
    $name = $1;

    $systemresult = system("mysqldu mp --opt --user=onehosts_t hirsty --password=$MySQL RootPassword $name > $BackupPath$

    }
    }

    close (DBLIST);

    }

    }
    [/code]
    Thanks for the help!
    Last edited by numberwhun; Feb 20 '08, 05:45 PM. Reason: add code tags
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Have you run this by hand to see if it works? If so, did it kick back any errors to you?

    Comment

    • WinblowsME
      New Member
      • Jan 2008
      • 58

      #3
      On line 45, change ¦¦ to ||.

      Comment

      • overcomersonline
        New Member
        • Feb 2008
        • 3

        #4
        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!

        Comment

        • overcomersonline
          New Member
          • Feb 2008
          • 3

          #5
          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("mysqld ump --opt --user=onehosts_t hirsty --password=$MySQL RootPassword $name > $BackupPath$""
          Execution of /home/onehosts/cronjob/backup.pl aborted due to compilation errors.

          Thank you for your help!

          Comment

          • WinblowsME
            New Member
            • Jan 2008
            • 58

            #6
            On line 50, remove the last $ and replace it with ");

            Comment

            Working...