Reputation: 533
I have created a PHP script which will send mail by a provided mailing list continuously after 10 seconds, but it works if i keep it open in my web browser, but is there any way to run this script on my hosting server from itself, so that i need not always keep my browser and internet connection on, this script will work in server itself continuously though my computer is turned off?
Upvotes: 2
Views: 5114
Reputation: 375
Assuming you facing problem with command field,
In the Command to run: field, enter the full path to your script (you may need to check with your host for this).
If you want to run a php file, the command will begin with php. For example, if you want to run RSS Import to update your Pligg feeds, you’d enter php and the path to your import_feeds.php file.
On AN Hosting, your path would look something like this:
php /home/[your username]/public_html/rss/import_feeds.php
If you want to run the automatic backup script, which backs up your MySQL database and emails a copy to you (see 8 MySQL Backup Strategies for WordPress Bloggers (And Others), strategy #7), you’d enter /bin/sh (since this is a shell script), and the path to your script.
On AN Hosting, your path would look something like this:
/bin/sh /home/[your username]/etc/upstart_cron_backup.sh
Hope this will help.
Upvotes: 3
Reputation: 57670
Run this as a daemon or as a cron. For cron you can run it as low as every 1 min. Cron does not support bellow that. The cron entry will look like this,
# m h dom mon dow command
* * * * * /usr/bin/php /path/to/project/file.php
For daemon basically you run this script from command line. In the script you run a while loop with 10 second sleep.
while(true){
// do stuff
sleep(10);
}
Daemon solution is more flexible but hard to implement. For this you must deal with signal handling to handle Ctrl+C or KILL
signal, forking dameon, logging.
Upvotes: 2
Reputation: 5615
you can run it via cron...
SSH to your hosting provider
and go to your crontab, using crontab -e
and set a cron every set amount of time which will use wget.
wget [options] [url]
search google for crons on how to do this properly
EDIT: if you don't have access to SSH, and you're using windows, you can set a scheduled task, which is the crippled brother of the cron job. you can run a php script which will simulate wget. I suggest running a scheduled task to a *.bat file which run php via console
doThis.bat
php [script-location]
Upvotes: 0
Reputation: 2564
You need to use a cron job for this. Cron job can run on regular intervals set by you.
Upvotes: 0