Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php cron backups

Status
Not open for further replies.

arago

Technical User
Mar 4, 2003
7
0
0
FR
I am trying to set up an automatic db and files backup system and since all I know of Linux is rather scarce I can't figure out what I'm doing wrong with the relative or absolute paths to have a php script run through cron. The script itself doesn't seem to be a problem; manual backups work allright.
**********************************************
Linux server (dns hostname) 2.4.21-40.EL #1 (all I could find in phpinfo)
Php 5.05 as Apache module (1.3.31)
Access to cron through Cpanel GUI
No shell access
Host emergency 24X7 support ... dead
File permissions for script directory set to 755
***********************************************
Here is the script to be executed, bckpp.php:
Code:
<?php
// This code was created by phpMyBackupPro v.1.8 
$_POST['db']=array("db_bcal", "db_cbr", "db_frm",  );
$_POST['tables']="on";
$_POST['data']="on";
$_POST['drop']="on";
$_POST['zip']="gzip";
$period=(3600*24)*0; 
$security_key="e9bb66605399852f9d91327e8b230977";
// This is the relative path to the phpMyBackupPro v.1.8 directory
@chdir("../bckp/");
(- and I tried this also
@chdir("/home/myusername/public_html/bckp/");)
@include("backup.php");
?>
"backup.php" being in hxxp://wxw.domain.tld/bckp/

Now the cron command through Cpanel's GUI (frequency for test purpose only):
Code:
* * * * * curl -s -o /dev/null hxxp://wxw.domain.tld/tmp/bckpp.php

And the cron daemon's reply:
Code:
/bin/sh: line 1: backups: command not found

I also tried to create a cron.daily file in the etc folder (/home/myusername/etc/) with the code in it. Nothing ... but I haven't understood whether cron.daily is a file or some special directory.

Anyone ? Thanks.
 
Could it be that you need the shebang?

#!/usr/bin/php

I think this is required on Linux.
 
So this, #!/usr/bin/php, is called a 'shebang'.
Maybe mistakenly I thought this was for when php is compiled as a cgi binary and not an apache module which is my server's case.
I have already tried it anyway, pasting it at the very beginning of the script, before the php tag, with the same reply I previously mentioned:
Code:
/bin/sh: line 1: backups: command not found
.
I believe it is a matter of wrong path but my host doesn't reply to inquiries about how the blXXXdy server is set up and I ain't much good at guessing. Thanks
 
You would have to ensure that is the correct path to php. Did you verify? I could be wrong. This isn't my area of expertise, but I just noticed that was missing and thought it was necessary.
 
Hi.
"You would have to ensure that is the correct path to php. Did you verify"
How can I do that? I checked phpinfo and didn't find anything relevant, or I missed it. Can you be more explicit ? Thanks
 
What I mean is, is /usr/bin/php the correct path to your interpreter? If you cd to /usr/bin and do a "ls php", does it show up in the list of files?
 
Good morning,
I don't know what is the correct path and I cannot do what you say "cd to /usr/bin and do a "ls php"" because I don't have command line access,unless there is another way ?
 
Not unless you have other php scripts that are working. In which case, you could just look at those to see if they have the shebang.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top