I am trying to get a file to work using cron but its just not happening, this is what I have in the command section /home/desiouk1/public_html/filename.php Code (markup): any know what I am doing wrong? the reason I want to use cron is so I can have a backup of the database I can get the following code to work with php but not on cron mysqldump --user=desiouk1 --password=**** desiouk1_desiguy --quick --result-file=/home/desiouk1/etc/db_backup.sql Code (markup):
Try something like this, (confirm the location of the php executable on your server): /usr/local/bin/php -q /home/desiouk1/public_html/filename.php Code (markup):
thanks for replying joeo, i've tried your suggestion and it doesnt work for me how do i find the php executable location on my server? will it be on phpinfo()?
If it is just a PHP page you want to get parsed, and you do not have the command line PHP compiler installed, you can also just let curl,lynx or any other tool fetch that page: curl http://www.mydomain.com/filename.php
ugh, i'm a n00b with all this so please can you explain in laymans terms? i've got cron (i'm using cpanel) and am trying to use that to run a file periodically. if i enter curl http://www.mydomain.com/filename.php into cron does that mean it will work?
ah , sorry for the tech-talk piniyini, as you were talking about cronjobs I assumed you know a bit 1) your first option is using the php command line tool, but that is not standard installed on a server when installing apache+php+mysql. so first check if you have it installed somewhere in /usr/bin or /usr/local/bin (using ftp or so) 2) if you do not have php (command line) instaled, you can let a tool fetch the url every hour. There are several tools that do that: curl, lynx, wget etc. e.g. if you create a cron entry: lynx -dump -source http://www.domain.tld/file.html , file.html will be downloaded. hope this helps ..
On my server I found the location of the php executable using "php -info"... I am not sure if this is standard for every server. I just setup my first cron job a couple days ago, took me a while, wget or lynx didn't work for me. I needed to run the command line php.
lol thanks frank... I really should learn some more basic unix commands, that would have saved me a headache the other day
You could try putting your back up command in a shell script and run that from cron. To do that, you would copy the code below into a plain text file, name it something like 'backup.sh', and then upload to server. This could be enhanced to add a unique date to backup file name, or to email you the file etc etc. --------------------------- #!/bin/sh mysqldump \ --user=desiouk1 \ --password=**** \ desiouk1_desiguy \ --quick \ --result-file=/home/desiouk1/etc/db_backup.sql
I'll try all your suggestion later as I'm in uni at the mo and cant access cpanel from these servers. Will get back to you all. Ta
Now this is really getting on my nerves frankm, no I dont have any on those folders in my ftp and the second point you mentioned is not working for me in cron. michele, I understand what you are saying but I cant run a file through cron! Is there anyway my host could have cron but not have it active?
It is possible that your server is not set up to run php scripts from the command line, I had to install something to get that to work on mine, but cannot remember what exactly it was... Anyways.. try this. <?php $whereisphp = `which php`; echo $whereisphp; echo "<p></p>"; $phpversion = `php -v`; echo $phpversion; ?> PHP: Make a file called whatever.php and then open that in your browser. That will tell you exactly where php is.. usually in /usr/bin/ or /usr/local/bin/ If you get something in return from the php -v command then i think that'll mean you can run php from the command line... I have been able to run php scripts from cron using cpanel with the following php /full/path/to/phpscript/script.php Code (markup): Hope that helps...
rederick, this is what I get when I run the script /usr/local/bin/php PHP 4.3.11 (cli) (built: May 23 2005 18:24:54) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Zend Extension Manager v1.0.8, Copyright (c) 2003-2005, by Zend Technologies with Zend Optimizer v2.5.10, Copyright (c) 1998-2005, by Zend Technologies I have tried all sorts to get cron to work but to no avail, I'll send an email to my host thanks for everything guys, I'm gonna get to the bottom of this!
If you have shell access, you can use crontab -l Code (markup): to check what commands your user has installed in cron. If you post the results of that command here, maybe we could help if it was a syntax error or something.
I'd be looking for a new host if the cron can be down that long without them doing anything. Or at least constantly check up on it to make sure it is still running.
Both things I wanted to do with cron are now working, thank you very much to all you guys! and Joe, I am waiting for my hosting to expire (don't hear that everyday) and then, poof - I'll be gone.