Koozali.org: home of the SME Server
Legacy Forums => General Discussion (Legacy) => Topic started by: cyberdude on February 27, 2005, 12:01:52 PM
-
Hi
I am in the process of setting up some database backup / dump on my SME and cant figure out how to get cron to activate a php file
I have the following code in my php file
<?
$nu = time();
exec('mysqldump --databases my_db --add-drop-table > /home/e-smith/files/ibays/hg_/files/backup$nu.sql');
?>
And when the cron passes the comand for this script it just outputs this error:
/home/e-smith/files/ibays/ddpnet_/html/dbdump.php: ? : No such file or directory
/home/e-smith/files/ibays/dd_/html/dbdump.php: line 2: syntax error near unexpected token time()'
/home/e-smith/files/ibays/dd_/html/dbdump.php: line 2: $nu = time(); '
If i just enter this in the file
mysqldump --databases my_db --add-drop-table > /home/e-smith/files/ibays/hg_/files/backup.sql
it outputs the backup / dump file with no errors
The cron job entery look like this
#(db dump 2)
45 * * * * root /home/e-smith/files/ibays/dd_/html/dbdump.php
I want to add the timestamp to EVERY file, or just the timestamp.sql for the filename
But how shoud the script looks like when i'm not able to just run the php script?
is it posible to set up in a non php file or how ??
-
You should explain to linux, that you want php to run the script, so start the script with:
#!/usr/bin/php -q
<?php
Or, you can change the cron entry to something like:
45 * * * root /usr/bin/php -q home/e-smith/files/ibays/dd_/html/dbdump.php
-
hi...
If i put the
#!/usr/bin/php -q
I get this error for the corn:
/bin/bash: /home/e-smith/files/ibays/dd_/html/dbdump.php: /usr/bin/php: bad interpreter: Permission denied
But if i put it directly in the cron job line like this :
16 * * * * root /usr/bin/php -q /home/e-smith/files/ibays/dd_/html/dbdump.php
It went almost okay, except i got a php warning mail...
Failed loading /usr/lib/php4/php_accelerator_1.3.3r2.so: /usr/lib/php4/php_accelerator_1.3.3r2.so: cannot open shared object file: No such file or directory
I know that this "bug" come up becourse that on the server the script is running the php file i miored from another server with this script installed, and it is not (yet) installed on this server
So what the diferent is between this 2 options you posted is and why only the one worked for me i dont know, but tha fackt is that itøs working :-)
Thanx
You should explain to linux, that you want php to run the script, so start the script with:
#!/usr/bin/php -q
<?php
Or, you can change the cron entry to something like:
45 * * * root /usr/bin/php -q home/e-smith/files/ibays/dd_/html/dbdump.php