nimrod
nimrod

Reputation: 5732

Does PHP provide a cronjob like function?

Is it possible to create recurrent actions with PHP?

I want to execute some statements every day at 10 o'clock. I know this could be done with cronjobs, but I only have a regular webhoster that does not provide Unix access.

Upvotes: 0

Views: 562

Answers (2)

nimrod
nimrod

Reputation: 5732

I found a way to fire cronjobs without Unix installed on a machine.

http://www.easycron.com/ provides cron services:

EasyCron is a task scheduler which provides services of calling URLs at specified time or by time interval. Once register with us, you get abilities to:

Some of the features:

  • Get Email notice about cron jobs' execution. (Applied to premium users)
  • Random cron jobs.
  • Cron job with cookies supported. (Applied to premium users)
  • Cron job executed using POST method. (Applied to premium users
  • View execution logs of each cron job. (Applied to premium users)
  • Cron job run time predictions. (Applied to premium users)
  • Manage online cron jobs at your own user panel.
  • Set cron job according to the date and time in your own account timezone.

I am not conntected to this service in any way, but it provided the solution I was looking for.

Upvotes: 1

deceze
deceze

Reputation: 522175

No, PHP does not have anything equivalent. PHP in conjunction with a web server is made to execute small scripts for a very short period of time. In order to execute something at a specific time, a PHP script would have to stay running permanently and check what time it is. You can do that in PHP, but likely not on a limited web host that optimizes for short-in-parallel scripts.

Lacking the ability to run a permanent script, and lacking any help from the system itself (cron), the only thing you can do is to make a normal web request every day at a specific time to trigger the action. I.e. the timer is on an external system that pokes your system at a specific time. That's an ugly workaround hack. Look for a better host if you want something nicer.

Upvotes: 2

Related Questions