Right CronJob Path for Kirby

I’m tried following path but didnt work:

/usr/bin/php -q /home/astalavista/public_html/index.php /api/test

What right cronjob path for Kirby?

There is no such thing as a “Kirby cronjob path”.

Kirby has no CLI by default, but you can create one yourself by creating a PHP script that includes Kirby’s bootstrap.php file. The Kirby system.php can be a good starting point to see how to initialize Kirby.
The script then has access to your site’s content and can do whatever it wants with it, just like in a plugin.

BTW: The -q option doesn’t make any sense on the CLI.

Hmm, so unlucky…

So kirby()->request()->cli() function is what for ?


You don’t need that, because the custom script you need to write contains code that is only ever run on the command line (you only call it from your cronjob).

Thanks! I created new file as cron.php included bootstrap.php :wink:

Side node: Make sure the file can’t be accessed over HTTP to prevent people from directly triggering the script.

Tried kirby()->request()->cli() but didnt work.

What were you trying to achieve? As I said, you don’t need that method for your script.

My cron.php

It’s working perfect except kirby()->request()->cli().



// load kirby
require(__DIR__ . DS . 'kirby' . DS . 'bootstrap.php');

// check for a custom site.php
if(file_exists(__DIR__ . DS . 'site.php')) {
  require(__DIR__ . DS . 'site.php');
} else {
  $kirby = kirby();

	exit("No access!");

if(isset($_GET['method']) and $method = $_GET['method'])
		case "test":

function test()
	return "Hello World!";

My recommendation is to move the script outside of the webroot so that it can’t be accessed in the first place. You can set the roots like in the system.php file.

BTW: $_GET in a CLI script?