This question already has answers here:
How can I make my PHP script run at a certain time everyday? [duplicate]
(8 answers)
Closed 5 years ago.
I have to send emails automatically on weekend basis by checking database values without form submission or button using codeigniter.is there any idea. someone please help
PHP call with CRON
If what you want is run a php script (that send emails or do what ever you want) automatically, use CRON on your server (if you are on Linux of course) by editing crontab with this command :
crontab -e
Add this line in the end of the file and save it :
0 8 * * 0 /usr/bin/php /home/toto/test.php
This example execute the script test.php in toto home directory every sunday at 8 AM.
More info on how to use cron here : Execute PHP script in cron job
PHP call from MySQL Trigger
There is another way to call a PHP script automatically every sunday or when ever you want, by creating a Trigger on MySQL. Especially if you can't use CRON, on Windows for example (WAMPP). You will use the sys_eval commande in your Trigger procedure.
sys_eval("C:/xampp/php/php.exe -f "C:/xampp/htdocs/phpFile.php");
Here is a good example for this solution : https://stackoverflow.com/a/2763238/2282880
Note : On Windows Server, you could use scheduled tasks to ru the php.exe app too. But never tried.
Related
This question already has answers here:
How to create cron job using PHP?
(11 answers)
Closed 5 years ago.
I have a long PHP script (for scraping), It takes around 2 hours to execute, I want to run this on weekly basis, I have cron job option in Cpanel and i know how to use it, But i think it is not useful for that long scripts
I read some other answers about long PHP script, They say long PHP script should be executed via shell. I read this blog http://symcbean.blogspot.com/2010/02/php-and-long-running-processes.html But i couldn't understand anything,
I have never worked with shell, But i can spend time to learn it, But would it be possible to run the script via shell and also on weekly basis at same time automatically
When you run a cron job it basically runs a shell command of your choosing.
That shell command can be php <your_script_name_here>.php
I think anyway that cron job is the way to go (scheduled task on windows machine).
If you have a script fro scrapping I recommend you to use HHVM instead of php-fpm you gonna gain lots of performance.
And in second part you gonna need may be a worker or a job queue system to run your script via a cronjob.
If you insert data in your data-base don't insert row by row but create an array with all data and then insert all in one time. (there is lot of thing you can do to have best performance)
This question already has answers here:
How to run the PHP script at scheduled time
(4 answers)
Closed 9 years ago.
is there any way to schedule a php script or a mysql query to run automatically for example every day at 00.00??
I would like to automatically run some queries on a mysql database, is it possible to do it with mysql or php?
you can schedule php jobs using cron (if you're in a windows environment you need its internal scheduler) and mysql jobs with the internal mysql events scheduler
Yes it possible to do it. Check "Cron-jobs" every normal Linux server got one of that. You can tell him to run something at specific time every day.
USE cron on Linux like this:
crontab -e
add:
0 0 * * * /usr/bin/php /path/to/script/script.php
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How to execute PHP code periodically in an automatic way
I am trying to find a way in PHP to load specified script in a specified time, For example if the apache server can execute a specified script, Or mabye there is an option inside the php.ini so i can add files to load in a specified times.
For example:
I want to load the script example.php this file can be found inside the root directory at the location X/Y/example.php, What i want is that the Php engine/Apache Server will execute this script at 12:00, If anyone know a way doing so i will be very thankful, Thank you all and have a nice day.
Use cron
Cron is a daemon that executes scheduled commands. Cron is started
automatically from /etc/init.d on entering multi-user runlevels. Cron
searches its spool area (/var/spool/cron/crontabs) for crontab files
(which are named after accounts in /etc/passwd); crontabs found are
loaded into memory. Note that crontabs in this directory should not be
accessed directly - the crontab command should be used to access and
update them.
For more info:
croninfo.html
Wiki
cronjobs and GET is all you need
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to run a php script in cron
I need to run a php script at the scheduled time daily to update some fields in database and to send automated email. How I can do this?
Is it possible to write some service in XAMP server to run the script daily at scheduled time? I have no idea how to update database and send email automatically at the scheduled time. Can any one share some ideas or concepts?
I am using PHP and MySQL running in Linux Server.
Is it possible to write some service in XAMP server to run the script daily at scheduled time?
Create a Cron Job.
Look into CRON Jobs: http://en.wikipedia.org/wiki/Cron They will allow you to schedule multiple scripts to run automatically, without your intervention on a determined schedule.
you should use cron job, it will run your script automatically
http://www.thegeekstuff.com/2011/07/php-cron-job/
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
schedule an email in php
I want to schedule my php script which sends emails using windows services as the website is hosted in windows machine. I am looking for a solution which does not involve cron jobs. I want users to schedule a time and the windows service should execute my php email script on the scheduled time so that emails are sent on the scheduled user time. I want to write the entire code in php.
You don't have access to cron jobs on a Windows Machine ;) But, there isn't a way to do that without the window's scheduler unless you have a VERY active site where someone is always on it, and then you can check and run on each page load or something similar. Otherwise, I would write a script that checks the DB for when emails are suppose to be sent - and pull the ones that are suppose to be ran that minute (or half-hour, or whatever intervals you allow your users to select from), and schedule run that script every minute/interval via the windows scheduler.