Support

Admin Tools

#36545 error when lanching admintools-dbrepair.php script

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by toonetcreation on Wednesday, 02 February 2022 14:52 CST

toonetcreation

Hi Team,

 

Today I have a shell script which launch this file /www/cli/admintools-dbrepair.php

This shell script is scheduled with crontab (00 05 1 * * bash /home/user/database-optimize.sh)

Problem :

- when I launch this script manually /www/cli/admintools-dbrepair.php => works fine

- when I launch this script thanks to crontab 00 05 1 * * bash /home/user/database-optimize.sh => I get errors in atatched file

Any idea why?

Thanks

L.

nicholas
Akeeba Staff
Manager

If you look closely at the output you will see this line:

Content-type: text/html; charset=UTF-8

This means that you are using the PHP CGI/FastCGI binary, not the PHP command line binary. This is confirmed further below:

You are using PHP 8.0.15 (cgi-fcgi)

You have made a mistake in your CRON job line, using the wrong PHP binary (CGI instead of CLI). If you don't know what is the correct path to the CLI binary ask your host and edit your CRON job line.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

toonetcreation

OK I see.

here is my current cron job :

SHELL="/bin/bash"
00 05 1 * * bash /home/user/database-optimize.sh

and inside shell script, here is the command launched :

php /www/cli/admintools-dbrepair.php

nicholas
Akeeba Staff
Manager

Thank you for confirming my findings.

As I said above, you have made a mistake in your CRON job line, using the wrong PHP binary (CGI instead of CLI). If you don't know what is the correct path to the CLI binary ask your host and edit your CRON job line, replacing the php at the beginning of the line with the correct path to the PHP CLI binary.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

nicholas
Akeeba Staff
Manager

Correction: I meant edit your CRON job script, as the path to the PHP binary needs to be in the script.

Also note that the method you are using is unnecessarily convoluted. Instead of calling bash to parse a shell script which only runs a shell script you can simply have your CRON job run the PHP script directly, i.e.

00 05 1 * * /path/to/php-cli /www/cli/admintools-dbrepair.php

where /path/to/php-cli is the path to the PHP CLI binary (NOT CGI/FastCGI!!!), a piece of information which as I said you can get from your host, the only people who will know what is as they are the ones who have set up your server and by definition know the path to wherever they have installed each PHP binary. This is not something we can possibly know since we did not set up that server.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

toonetcreation

yes I know for the shell script, but this script is doing some others things, that's why I use it ;-)

thanks again for the feedback I will check with my host provider.

have a nice evening

L.

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!