Hi all,
Sorry if this sounds dumb but what command do I put down to run a PHP script?
I have a PHP script that would be say /email.php and I want to run this, what command do I have to type into the cron thingy in cPanel?
Cheers
Paul.
Hi all,
Sorry if this sounds dumb but what command do I put down to run a PHP script?
I have a PHP script that would be say /email.php and I want to run this, what command do I have to type into the cron thingy in cPanel?
Cheers
Paul.
The PHP interpreter is called php and it's at /usr/bin/php. The /usr/bin directory is probably on the execution path list so you may not need the prefix but it never hurts to add it. Also, you'll want to make use of the $HOME variable - this variable contains the name of the directory that contains your public_html.Originally Posted by probedb
Unless you also need to be able to access such scripts from the web I would recommend not placing them in the public_html sub-tree since anyone in the world can run it (assuming they know its name, of course). So let's assume that you create a directory called "script_dir" that is a peer of public_html and you place email.php in that directory. The cron command to execute the script would be:
In some cases, it is useful or necessary for the "current directory" to be the script directory while it executes. This can be arranged using a slightly more complicated cron command:Code:/usr/bin/php $HOME/script_dir/email.php
Code:(cd $HOME/script_dir; /usr/bin/php email.php)
Don Kinzer
ZBasic Microcontrollers
Awesome, thanks very much for thatWorking a treat....except that the simple view doesn't work properly! Ah well managed to sort it using the Unix view to get it working every hour.
hey, another newbie need help with cron... similar challenge to the one above...
So if I need to get the file 'email.php' (which resides in "public_html/mydir" ) in the cron path then what I need to enter in the field is:
/usr/bin/php $HOME/public_html/email.php
Is this correct? Exactly as it's mentioned above?
Im trying to execute a php file at intervals using cron. if i call the file from my web browser it runs fine , but if i setup a cron job in cpanel , when the script runs , it just emails me a bunch of errors. is their anyway i can make this happen with cron?
Last edited by cade; 03-08-2009 at 10:05 PM. Reason: Neither "signatuer"s nor signatures are allowed for new members.
Does your script have include files? if so then the problem might be that the root folder is two folders higher for the cron job than it is for the same job run from a browser - the home or home1 folder rather than public_html.
I had a cron job to run a PHP script working once before, but I deleted it and now I forget how I had it setup and thought I'd ask for some clarification because I'm confused by the differences between what I've seen posted in threads about this.
Which of these is best, or does it matter?
For the first half of the command, the path to PHP:
Code:/usr/local/bin/php Code:/usr/bin/php Code:php
For the second half of the command, the path to the file:
Code:/home/public_html/mydir/thefile.php Code:$HOME/public_html/mydir/thefile.php Code:$HOME/mydir/thefile.php
Last edited by toronado; 07-29-2010 at 02:23 PM.
I use "php /home4/qalistsc/public_html/folder/xxx.php" at cron job option.. and it run well
http://www.qalists.com
http://www.beegadget.com
http://www.feeddiary.com
http://md5pass.com
http://www.liputra.com
Last edited by jepes; 08-10-2010 at 07:48 AM.
The first two values in the path (before public_html) will depend on exactly where your account is on the server.
The first will be "home" possibly with a number on the end and the second will be your account name. You'll have to check in cPanel for the exact details.