@KevinTheJedi I fixed the issue, so pelase close this case. Indeed the problem was the DB name selection. In CLI the url obviousely is missing, so it pushed to the config an empty value. With argv I gave it manually and it started to work.
So just for the reference for those people who use multitenancy here is my script for the ost-config.php:
define('DBTYPE','mysql');
define('DBHOST','localhost');
define('DBSITES','osticket_tenant');
define('DBUSER','osticket_user');
define('DBPASS','your_super_secret_password');
define('TABLE_PREFIX','ost_');
$url = $_SERVER['SERVER_NAME'];
if($url==''){
$url= $_SERVER['argv'][1];
}
$conn = new mysqli(DBHOST,DBUSER,DBPASS,DBSITES);
$sql = "select * from tenant where url = '$url'";
$res = $conn->query($sql);
$row = $res->fetch_array();
if ($url == $row['url']) {
define('DBNAME',$row['db_name']);
} else {
define('DBNAME','demo');
}
CRON JOB:
*/5 * * * * /usr/bin/php /www/osticket/api/cron.php YOUR_URL