Results 1 to 6 of 6

Thread: Cron finds a syntax error

  1. #1
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default Cron finds a syntax error

    Hi I am trying to setup a backup for a site. Cron finds the backup.php file but states that there is a syntax error. Here is the error:

    Code:
    /home/theurl/tomy/script/backup/bk.php: line 3: syntax error near unexpected token `('
    /home/theurl/tomy/script/backup/bk.php: line 3: `$date = date("F-j-Y-g-ia");'
    Here is the script:

    Code:
    $date = date("F-j-Y-g-ia");
    echo exec("cd /home/theurl/tomy/backuplocation/backup/files;tar -cvpzf ibc-$date.tar /home/theurl/to_public_dir");
    I have tried this with
    Code:
    <?php
    tags and without them. When the php tags are in the script they too return an error. Anyone have any idea what I am doing wrong?

    Thanks
    Last edited by itivae; 06-23-2012 at 08:16 PM.

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by itivae View Post
    Code:
    /home/theurl/tomy/script/backup/bk.php: line 3: syntax error near unexpected token `('
    /home/theurl/tomy/script/backup/bk.php: line 3: `$date = date("F-j-Y-g-ia");'
    is that backtick (highlighted) in your actual script? : )

  3. #3
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    No those backticks are not in the script. The error is emailed to me so that is were those backticks appear.

  4. #4
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default Update

    So I figured out how to make this work using
    Code:
    #!/usr/bin/php -q
    But I am getting another error message on run. Message is one of the following:

    Code:
    tar: Removing leading `/' from member names
    tar: ibc-June-20-2012-7-08pm.tar: Wrote only 8192 of 10240 bytes
    tar: Error is not recoverable: exiting now
    or

    Code:
    tar: Removing leading `/' from member names
    tar: /home/path/to/backup/files/ibc-June-20-2012-6-08pm.tar: file changed as we read it
    Does anyone know what this means? Is it a timeout error?

    Thanks

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    tar needs relative paths, not absolute. try this (untested):
    Code:
    cd /home/theurl/tomy/backuplocation/backup/files;tar -cvpzf ibc-$date.tar -C / home/theurl/to_public_dir
    reference

  6. The Following User Says Thank You to traq For This Useful Post:

    itivae (06-23-2012)

  7. #6
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    Thanks for the help that and a few variations seem to be working.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •