2

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.

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
Praveen Prasad
  • 31,561
  • 18
  • 73
  • 106
  • They're called cron jobs. I'm not going to bother explaining them because there are millions of pages on Google that do that already. – animuson May 12 '10 at 06:24
  • duplicate of http://stackoverflow.com/questions/984622/what-options-are-there-for-executing-a-php-script-at-a-certain-time-every-day , http://stackoverflow.com/questions/1981036/php-script-to-execute-at-certain-times , etc. – ax. May 12 '10 at 06:36

5 Answers5

4

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.

Russell Dias
  • 70,980
  • 5
  • 54
  • 71
1

You can use a Cron job to call a PHP script at certain intervals.

alex
  • 479,566
  • 201
  • 878
  • 984
1

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.

Soufiane Hassou
  • 17,257
  • 2
  • 39
  • 75
0

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.

Allen Mak
  • 51
  • 3
0

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.

Martin
  • 10,294
  • 11
  • 63
  • 83