user474632
user474632

Reputation: 311

How to periodically update php?

I need my site to occasionally read a file in order to update itself. (Daily or weekly if possible)

Is php capable of this alone? (From what I've seen the answer is "no")

What else can I use to do this? (Sql seems like it might work, but I've searched and can't tell for sure)

Upvotes: 0

Views: 439

Answers (4)

David Cooke
David Cooke

Reputation: 141

Cronjobs are the obvious answer (for linux based servers). However for people who don't have the ability / permissions to do this on their paticular environment.

The other option is to build a simulated cron. Which basically executes a script every time the site / page is loaded. This could then check the current time / date and decide whether it needs to perform further operations, in your case the update operation.

Upvotes: 1

KeatsKelleher
KeatsKelleher

Reputation: 10191

Use Cron:

crontab -e

Then you edit the file like in vim or vi.

http://blog.linuxvin.com/wp-content/uploads/2010/07/crontab-syntax.gif

This would execute everyday:

0 0 0 0 0-6 /absolute/path/to/the/executable

If you want to make your php script executable use the ol' she-bang. Add:

#!/usr/bin/php

or whatever the path is to your php interpreter to the first line of your PHP file and then do:

chmod a+x yourfile.php

Upvotes: 0

nocksock
nocksock

Reputation: 5527

You could use a cronjob that executes your php-script at a given interval (eg every day at 12pm).

In case you cannot use real cronjobs: there are also some sites that offer free "cronjobs" - you give them a URL and they visit it at the time you tell them to. Just google for "free cronjobs".

Upvotes: 3

Aif
Aif

Reputation: 11220

You can use crontables on unix system to run periodical updates.

Upvotes: 0

Related Questions