I am trying to run following script in cron job section of cpanel but i am not getting any mail and my database is also not getting updated as script updates the database.
/usr/bin/php /home/allsamac/public_html/getlinks/abc.php
php -q /public_html/getlinks/abc.php
In crontab system :
1./usr/bin/php is php binary path (different in some systems ex: freebsd /usr/local/bin/php, linux: /usr/bin/php)
2./home/username/public_html/cron/cron.php should be your php script path
3./dev/null should be cron output , ex: /home/username/stdoutx.txt
So you can monitor your cron by viewing cron output /home/username/stdoutx.txt
Related
I have 2 server one is with cPanel and other is without cPanel
i am running same php scripts as cron jobs on both servers.
All scripts are running fine on cPanel server but on non-cPanel server i am getting file not found error
Failed opening required '../includes/config.php'
i have 15+ cron job php scripts.
is there any way to fix this without editing all my php scripts and adding __FILE__ on all includes and required?
how all these scripts running fine on cPanel without __FILE__?
The cron may need to run the script from the directory it's in. You could update the crontab to cd to the script directory, then execute it, like so (example):
0 12 * * * cd /path/to/your/script/ ; php your_script.php > /dev/null 2>&1
This is what i want to do in a batch file:
write a file to ftp folder
run php script (http://mylocation.url/script.php)
download a file from ftp folder
FTP i have read before, it is possible to do it in a batch file.
But i don't found a way to execute my php script on my linux server.
Cronjob is not possible for this solution cause the uploaded file will be changed from
Scipt and after i need it downloaded again.
Any one has a solution?
Thanks for help
Phil
plink tool can be used to execute commands in Linux server from Windows through SSH. Below is the syntax
plink.exe root#10.0.0.1 -pw password "<ur script execution command here>"
Say if I want to run a shell script I would type in the command "sh myscript.sh". To achieve this the Linux server should have sshd running.
The command can be used along with other commands part of the batch file.
I have a remote Apache/2.2.16 (Debian) Server where I want to do intervalled jobs like every 2 hours do this, at 12.00 do this. So, I wrote a php file which can do this but I have to start it via the browser and have to keep the browser window open to keep the script running. I heard I could execute a php script via console, but I don't have access to it.
How can I run the script without access to the console and without having my browser opened?
Set up a cron job for this task. You can set this up on the server or on any other computer that runs at the given time.
On a Linux or Mac OS machine, open a terminal and type crontab -e.
Add something like this to the end of the file:
0 12 * * * wget http://url.com/your/script.php -O /dev/null
This will call the script every day at 12:00. Make sure wget is installed.
I am trying to set up a cron job on my localhost to call a php script every half an hour 24/7. Following are my steps:
1) I have created a cron.php file to call myscript.php:
<?php
echo exec('*/30 * * * * C:\BitNami\wampstack-5.4.21-0\php -f C:\BitNami\wampstack-5.4.21-0\apache2\htdocs\myscript.php');
?>
2) Created a cron.bat file to run the cron.php on browser:
"C:\Program Files\Mozilla Firefox\firefox.exe" "localhost\cron.php"
3) Then I have set up a windows 7 task scheduler to call cron.bat every day.
I welcome any idea on how to set up a cron job as my approach doesn't do anything.
Thanks
This is not an answer, but only pointers you need to check before you proceed further.
Crons are available only on unix systems, not windows.
While debugging cron or anything similar, schedule them for every minute or (any such acceptable smaller frequency), and once they work every minute, only then schedule them for the original frequencies. That will save you some time during debugging.
Its an incorrect call to exec. You don't have to pass all those * in it
Since this is windows, You want to do php.exe and not C:\BitNami\wampstack-5.4.21-0\php -f which would have been done in linux (with proper path)
Your .bat file is currently scheduled daily, you need to schedule it every half hour.
you don't need to creat .bat file to run php script
follow the step to setup cron job for php interpreter..
step 1- Then I have set up a windows 7 task scheduler to call php script by giving path of php interpreter like C:\xampp\php\php.exe filename.php by setting desired interval
dude, you cannot define cron jobs in wamp,
the cron is a linux feature and you are running the wamp on windows.
you can run the script from the command line (of from cygwin, much better),
something like "/php.exe "
but you cannot define crons on wamp
but you can setup the scheduler to run a .bat file that contains the next code
cd/
cd "Program Files (x86)"
cd GnuWin32
cd bin
wget.exe http:// localhost/... (your file)
echo DONE
can you help me setup cron job on godaddy webhosting? I have php file that i need to run, it is located in cron subdirectory (so address is http://test.com/cron/file.php).
What do i need to write in command input field, so this file is runned?
NOTE: GoDaddy has been migrating all hosting packages over to cPanel. The itemized instructions below are for the older GoDaddy interface. The command is still the same.
At the time of this writing, on GoDaddy shared hosting, i could NOT use the following commands: ping, curl, nc, lynx
but i COULD use: wget
I successfully created a cron job using wget to load a PHP file containing a call to mail().
log into your GoDaddy account
click to expand the "Web Hosting" section and find the server in question
click the "Manage" button (it used to be labeled "Launch")
on the "Hosting Details" page in "Tools" section, click "Cron Job Manager" button
on the "Cron Job Manager" page, click "Create Cron Job" button
enter the title you want and select the frequency (1 hour is the most frequent allowed EDIT: GoDaddy has added 15-minute increments to the frequency choices.)
enter the command below (with your info):
wget http://YOUR_DOMAIN/YOUR_PATH/YOUR_PHP_FILE.php > /dev/null 2>&1
edit: as noted by Leandro, this is the method to make a cron job call a remote or local resource -- consult GoDaddy documentation if you want to call a resource locally only (which is also more secure if you're running more sensitive jobs)
in "YOUR_PHP_FILE.php" code all the actions you want to be performed and include a call to mail() (or whichever mail method you may want to use assuming you have configured that properly).
By using mail() the SMTP relay server will already be set properly in the "php.ini" file to: relay-hosting.secureserver.net -- which you can confirm using phpinfo().
php_path -q file_name_with_absolute_path
/usr/bin/php -q /home/[user name]/public_html/test.php
1: How to know your php_path?
echo exec('whereis php');
2: How to know absolute path of your file?
echo dirname(__FILE__);
Cron Setup for GoDaddy Shared Hosting Accounts using Cpanel.
*-->>Cron jobs run on GoDaddy's time zone in Arizona. Go Daddy doesn't publish this anywhere.
Example:
Run cron everyday at 1305 (1:05pm) pacific standard time.
5 14 * * * /usr/local/bin/php -q /home/username/public_html/scriptname.php
Your cron job command should look something like the following (unless your directory structure is different of course):
/web/cgi-bin/php5 "$HOME/html/sendy/scheduled.php" > /dev/null 2>&1
Regrads,
shahana
If you are using Godaddy this should solve your issue.
* * * * * /usr/local/bin/php /home/path/to/your/file.php > /dev/null
In Godaddy Linux hosting. I used this command to run cron job.
/usr/bin/php public_html/now your path
Use, for example CURL or wget or lynx.
lynx -s http://link.to/script.php
/usr/local/bin/php -q /home/[user name]/[path to the file]
Reference
You can setup cron jobs through the Hosting Control Center. Check out GoDaddy's official page here: https://www.godaddy.com/help/create-cron-jobs-3548 for a how-to on setting it up.
If you want to run a cron job in Godaddy. You can find following command, it will surely help you.
php -f /home/[user name]/[path to the file]