Maintenance script not run from command line

Dear all,
I’m quite new to Xibo (we are running it from some months now) and only today I discovered the maintenance script!
So I tried to setup the script as per instructions, but when calling it from command line (Debian 7 server) with

/usr/bin/php /var/www/xibo/maintenance.php secret

it seems not doing anything. I try to explain better:
I have run the command in that way for the first time ever in my installation, and it did exit immediately. I thought it was strange, as surely it should have been cleaned the stats table, so I launched it repeatedly, even without the secret key to see if some messages would appear at command line, but same quick exit without any output.
So I launched it from browser, and actually it took some minutes to complete, with the final messages saying success.

I’m at 1.7.4 version, upgraded today from 1.7.1.

Trying to debug this problem, I commented out the first lines suppressing error reporting, and here is the problem, launching the script from another directory:

PHP Fatal error:  require_once(): Failed opening required '3rdparty/php-gettext/streams.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/xibo/lib/app/translationengine.class.php on line 23

If I launch the script from the same /var/www/xibo directory, it works.
As I’m not very expert in coding, what can be done to make this script work when called from everywhere?
Can it be considered a bug?

Thanks in advance!

You would need to add your Xibo installation directory to your PHP include path, or as you say call it from the correct working directory.

It would be trivial to write a little bash script that changed to the correct directory and then ran maintenance.php from there - so that would be my recommendation to you.

Or use curl/wget to run that via the webserver.

Thanks Alex, I’ll make a cd in the cron job before launching the maintenance

*/5 * * * *  root cd /var/www/xibo && /usr/bin/php /var/www/xibo/maintenance.php secret > /dev/null

(it’s not in the root crontab, but in a file in /etc/cron.d)