Reputation: 32107
I need to run a code again and again on server after a fixed time. Is it possible to do so?
I am using PHP.
Upvotes: 2
Views: 7845
Reputation: 10563
In your hosting control panel you should have an option to set a Cron Job that can be used to run a PHP script at any interval. The command you need to use should look like this:
/usr/bin/php -q /home/USERNAME/public_html/PathToFile
The cron setup will allow you to setup how often your script will run, every minute, 5 mins, hour, daily, weekly, etc.
Upvotes: 0
Reputation: 51
Please use Cron job to accomplish the task. You may execute php cli to start the PHP engine in command-line mode. You can modify a setting text file to instruct Cron job when to execute.
Upvotes: 0
Reputation: 17750
What you need is called Cron
From the Article
Cron is very simply a Linux module that allows you to run commands at predetermined times or intervals. In Windows, it’s called Scheduled Tasks. The name Cron is in fact derived from the same word from which we get the word chronology, which means order of time.
Upvotes: 1
Reputation: 73282
You can create scheduled tasks through CronJobs.
Also have a look through this article to run PHP scripts through Cron.
So basically what you will have to do is create the script you want to run via PHP and using the above articles create a Cron for the specific interval.
Upvotes: 4