Run/access public function via cronjob

Hey guys,

is there a way using a cronjob to run/access a public function in a controller?

You can use a command controller, and execute the flow CLI tools from cron.

Thank you for your answer.
Is there any documentation for command controllers and/or the flow CLI tool?

Ok, I have found the docs:

See especially

Take a look at the ttreeagency/Scheduler TYPO3 Flow Package. It handles multiple task executions without the need to implement each task (cronjob) as a commandline controller.

If you can read german, here is a short blog post about this package

That reming me to push a bit more love in this package, is you have any questions/problems, feel free to open issue on github:

I have tried this with a command controller. It works, but I can’t run a database query (persistenceManager) in the command controller. I get “undefined property…” in my Logfiles.

21 TYPO3\Flow\Error\ErrorHandler::handleError(8, “Undefined property: My\Projekt\Command\CronCommandController::$persistenceManager”

… and this is my command:

* @return void
public function brewCommand() {

	$classname = '\My\Projekt\Domain\Model\Send';
	$query = $this->persistenceManager->createQueryForType($classname);
	$results = $query->matching($query->equals('send', "0"))->execute()->getFirst();

Hi @patriceckhart,

First dont create query in your controller … it smell like bad code and fat controller syndrom (aka Controller that contain way to mus logic / code). Use a Repository to build your query and inject the repository in your controller. The logic that you put in a controller a pretty hard reuse and hard to test.

Based on the exception, you don’t have persistenceManager property in your controller. You can inject it, but try to build a repository and use the repository is way more clean way to do it.

Check the document for more informations:


Sorry for reactivating this thread…
I just want to use the sheduler from Dominique, but I’m getting
an exception

Class 'Cron\CronExpression' not found

This is ok since there is no such class/package in my flow installation.
Dumb question: where can I get it?
Does someone have a hint for me?

Sry, I don’t use the scheduler from dom.

My way: crontab -e on Linux, I have only one Controller and it is sufficient


If is anybody interrested: the schedular depends on two more libs:

1 Like

@mexoona Strange that you don’t get the dependencies automatically, they are declared in the composer.json (