Log in

View Full Version : Resolved Cron finds a syntax error



itivae
06-20-2012, 04:22 PM
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:


/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:


$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
<?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

traq
06-20-2012, 04:31 PM
/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? : )

itivae
06-20-2012, 05:32 PM
No those backticks are not in the script. The error is emailed to me so that is were those backticks appear.

itivae
06-21-2012, 12:35 AM
So I figured out how to make this work using


#!/usr/bin/php -q

But I am getting another error message on run. Message is one of the following:


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


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

traq
06-21-2012, 02:33 PM
tar needs relative paths, not absolute. try this (untested):
cd /home/theurl/tomy/backuplocation/backup/files;tar -cvpzf ibc-$date.tar -C / home/theurl/to_public_dir
reference (http://www.linuxquestions.org/questions/linux-general-1/bin-tar-removing-leading-%60-from-member-names-269508/)

itivae
06-23-2012, 08:15 PM
Thanks for the help that and a few variations seem to be working.