3

How can I get a function executed in a php (cakephp) application at a specific point of time, without the intervention of a person clicking the link or triggering the function by himself/herself?

2

4 Answers 4

4

All other answers so far are right, you'll need to schedule a cron job (or scheduled task on Windows). With that said, CakePHP is designed to answer HTTP requests and not work through the command line.

For a tutorial specific to CakePHP, visit http://bakery.cakephp.org/articles/mathew_attlee/2006/12/05/calling-controller-actions-from-cron-and-the-command-line.

Sign up to request clarification or add additional context in comments.

2 Comments

Your answer is partially correct. Cake has a pretty robust console system. Look at book.cakephp.org/view/110/Creating-Shells-Tasks and book.cakephp.org/view/846/Running-Shells-as-cronjobs
@William - Thanks! I had no idea we could do this.
1

If you are on Linux or Mac, try Cron:

Comments

0

Two things:

For Linux:

https://www.interspire.com/support/kb/questions/298/How+do+I+set+up+CRON+on+my+server%3F

For Windows:

http://troy.jdmz.net/cron/

There is one more stuff, the above method are done on your server machine, but if you are expecting to do this from a page (browser), then you have to use AJAX + setTimeout you can get it done.

Comments

0

Yes using CRON as the scheduler and then using cakePHP shells to execute the code you need.

Here's the documentation from cakePHP 2.0: http://book.cakephp.org/2.0/en/console-and-shells.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.