Create cronjob with Zend Framework

2020-02-08 02:47发布

I am trying to write a cronjob controller, so I can call one website and have all modules cronjob.php executed. Now my problem is how do I do that?

Would curl be an option, so I also can count the errors and successes?

[Update]

I guess I have not explained it enough.

What I want to do is have one file which I can call like from http://server/cronjob and then make it execute every /application/modules/*/controller/CronjobController.php or have another way of doing it so all the cronjobs aren't at one place but at the same place the module is located. This would offer me the advantage, that if a module does not exist it does not try to run its cronjob.

Now my question is how would you execute all the modules CronjobController or would you do it a completly different way so it still stays modular?

And I want to be able to giveout how many cronjobs ran successfully and how many didn't

13条回答
▲ chillily
2楼-- · 2020-02-08 03:33

I extended gregor answer with this post. This is what came out:

//public/index.php 

// Run application, only if not started from command line (cli)
if (php_sapi_name() != 'cli' || !empty($_SERVER['REMOTE_ADDR'])) {
    $application->run();
}

Thanks gregor!

查看更多
登录 后发表回答