2

I was looking for a php script that will get executed every hour ( without executing it ) ( ex. for sending emails ) but i don't know, the way it works. Do i have to use Cron Jobs or is there anything in php to make such kind of scripts?

Thank you

Rahul Dev
  • 135
  • 13

3 Answers3

8

PHP does not have anything like this included. You have to use an external tool, such as cron, to run a PHP script perdiodically.

If you are not allowed to set cron jobs on your web hosting, there exist websites that will call one URL periodically, like http://www.onlinecronjobs.com/.

Community
  • 1
  • 1
Wookai
  • 18,747
  • 16
  • 70
  • 85
1

You need to use cron jobs if you want it to run on a set schedule.

Matt
  • 6,745
  • 4
  • 24
  • 49
  • Thank you, but installing cron jobs manually is.. or i can do something with php script to install that cron job for me? – Rahul Dev Jul 27 '12 at 18:33
0

Yes, if you are using linux, go to the terminal and type crontab -e.

Your line will be something like that

1  2 3 4 5 (this line here is just an information.. dont type it on crontab)
00 * * * * wget www.page.com/yourphp.php

So the script will run 1 00 On minute 00 2 * Every hour 3 * Every day 4 * Every month 5 * Every day of the week

Then type :wq to close So its done.

You need to have the crontab and the wget in this scenario.

Lefsler
  • 1,678
  • 5
  • 25
  • 41