Question

So... for example I want to add to 1 five every 5 minuts (1 is in the DB)... With out direct calls from users....

So... How to make PHP code work without direct calls (on some kind of timer)?

Was it helpful?

Solution

build a script which does what you need to do. and call it via crontab in the needed interval but make sure its not callable from a user or searchengine.

see http://www.unixgeeks.org/security/newbie/unix/cron-1.html for more information on cron

a typical call could look like:

*/5 * * * *      lynx -source http://yourhost.com/yourscript.php >/dev/null

OTHER TIPS

If you are unable to schedule cron jobs on your server (as is the case with most cheap hosting solutions), there are some pure php alternatives to run scheduled jobs: phpjobscheduler is one of those alternatives.

Yes configuring a cron job is the correct answer. See the Wikipedia article for the syntax of a cron job.

You simply create a new cron job and let it request the page where the script is. The following cron job requests update.php every five minutes.

*/5 * * * * wget http://www.example.com/update.php

Update

Syntax with wget.

If I understood you correctly, CRON is what you're looking for (google it)

Cron is the obvious suggestion.

If you can only invoke your code via the web (i.e. no command line PHP) then you can call a URL using 'wget' or 'curl' on most *nix boxes.

Unless of course your code sits on a microsoft OS (which is unlikely to have cron available) in which case you can use the 'at' service to do the same thing - and there's a free wget.exe out there somewhere.

C.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top