How can I make my PHP script run at a certain time everyday? [duplicate]

By | February 23, 2018
Questions:

This question already has an answer here:

Answers:

What you want is called a cron job and is already covered here:

PHP: running scheduled jobs (cron jobs)

Questions:
Answers:

If you are using cPanel on your host, you can go to Advanced –> cron jobs.
Then inside there you can set a cron job command like this:

wget http://yoursite.com/yourfile.php

which http://yoursite.com/yourfile.php should point to your desired function.
You can also set repetition time interval over there.

This way yourfile.php is called in specified intervals.

Questions:
Answers:

CronJobs feature are often disabled on most free or cheap Linux hosting. If you could use cron you could use that.

Alternatives:

  • Use services like : http://www.setcronjob.com/ (many exist, just search on google) , to schedule your task for free(1x per hour).
  • If you need a little bit more juice you should look into google app engine cron. In the cron you just do a simple asynchronous request to call your page.
Questions:
Answers:

There’s a cli interpreter called php. Run your script through that as a cron job.

Questions:
Answers:

If you are a linux/unix user, i recommend you use CRON .

Questions:
Answers:

May it will helps you.

You can schedule a task in Windows – control panel->administrative tools is where you find task scheduler.

run a php automatically after every hour

Thanks

Questions:
Answers:

If you have your own server you can run a cronjob(unix/linux) or a scheduled task(windows).

If your app/site is hosted on a shared host that does not offer cronjobs you an use a sevice like
http://www.onlinecronjobs.com/

I have not tested this one but If you google a bit(fee conjobs) you will find plenty of those.
They will call a certain a url accoding to a fixed schedule. Most of those sevices have a fixed set of ip addeses so you can pevent the scipt from being called by anyone else.

Questions:
Answers:

You can easily use your database to save the last execution of the script.

Each execution of a certain page you run a script that does the following :

  • Check if more than 8 hours (example)

  • Checks in the database if the script has already been executed

If executed: does nothing.

If not executed: starts and updates the date last execution in database.

Leave a Reply

Your email address will not be published. Required fields are marked *