SuiteCRM Database Scheduler - php

I installed SuiteCRM and while trying to run the code below for for the Scheduler...
php.exe -f cron.php
I get the error:
Call to undefined function mysqli_connect()
Can anyone help?

Have you checked the mysqli PHP extension is installed? try viewing the phpinfo, either from a php phpifno(); or from the command line php -i.
If this wasn't installed it would effect the whole installation rather than just the scheduler.

Looks like your command line PHP ( PHP CLI ) refers to seperte location than your PHP.
Get path of php.ini for your command line and then uncomment this line.
extension=mysqli

The cron.php is run from the scheduler, but sometimes I have to run the code to make sure is working properly.
php cron.php all -F -vvv
where
the “all” command will execute all the tasks
The “-F” option forces all the tasks to be executed.
The “-vvv” option sets the output verbosity level to maximum.
If I need to edit my web server user's crontab file, I use this command:
sudo crontab -e -u username
If I need to find out the username the cron job is running on, I use the browser
domain.com/get_current_user.php
assuming I already created the get_current_user.php file.

Related

PHP exec on local script

Hello i have a PHP script, and its added to cron, it is possible to execute from this script shell command (with exec() or something) without enabling it on php.ini? I don't want to enable exec on my site
It's called PHP CLI, check here
Usually when you install php, there's option to install php_cli too.
So long you can run php on shell prompt, then it can work.
Open bash (or other shell), try this:
php -v
If the version printed, then it's working.
Then you can
php -f phpfile
or put
#!/usr/bin/php
At the beginning of your php file as a line, and chmod +x file.php, and then
./file.php
#or
/path/to/file.php
to run it.
(Note /usr/bin/php is the usual place of php executable, it might change, eg in unix is ually /bin/php. Use whereis php to check its place.)

php shell_exec return null

I want run php ../cat1/index.php gr_s2/3/gr-n40 1200 command by php.
The shell_exec return NULL as result but when I try that command on cmd, output was shown correctly.
What happen in php and shell_exec ?!
Note: The command with different parameters (Like: php ../cat1/index.php gr_s2/3/gr-n40 800) works correctly in both (php and cmd).
There is a note in php manual page of shell_execute:
Note: This function can return NULL both when an error occurs or the
program produces no output. It is not possible to detect execution
failures using this function. exec() should be used when access to the
program exit code is required.
Source: http://php.net/manual/en/function.shell-exec.php
So your code running with error. Try with exec.
If you want, insert your code (or blocks) to be checked.
This is fixed by adding user used by web-server to sudoer and run the php command with
sudo php ..........
To start run this command sudo visudo
Add the following line at the end of sudoer file opened
www-data ALL=NOPASSWD: /usr/bin/php
But if you whant to execute all commad from php add this line instead of the above www-data ALL=NOPASSWD: ALL which is not recommended
and the run your commands with sudo php /path/to/you/file.php
For my case I was running ubuntu 14.04
Have fun please

owncloud cron execution within docker

Im using php-apache image to create an owncloud installation. I want to use a system cronjob to execute cron.php, therefore I run:
RUN echo "*/3 * * * * php -f /var/www/html/cron.php >> /oc_data/cron.log" > /cron.conf \
&& crontab -u www-data /cron.conf
The entrypoint script starts cron with:
cron -f
It gets executed but the owncloud.log shows following message:
"app":"cron","message":"Failed to connect to the database: An exception occured in driver: could not find driver"
Fun thing is, if I enter the docker container and execute the command I use for the cronjob, it works. And php --ini shows all php conf.d extensions including mysql.so and pdo_mysql.so.
I also tried to add the cron.conf file as user root with the same result.
Any ideas, what is happening here?
Please use the correct folder to keep your cron files: "/etc/cron.d/", use COPY to copy the cron file to inside container and "cron -f" in CMD parameter instead ENTRYPOINT.
OK, ALWAYS use absolute paths!!
path of the php command using the bash in the docker container was different to the one cron used.
use which php to get the correct path and add it to the cronjob.

execute php script from command line on ubuntu

I can run facebook.php script from ssh below:
cd /var/www/
php facebook.php
But I want to run to script 1 line command because i want to use it on cron. Like this:
php /var/www/facebook.php
I tried other commands on ssh but dont worked. Only first command is worked for me
if /usr/bin/php /var/www/facebook.php is not working, it might a case of your php path is different then /usr/bin/php.

linux - running php script from command line when php is installed as apache module

Normally when I want to run a php script from the command line I just create a php page, add a shebang pointing to the php binary, then ./file.php to run it. Since I have php installed as an apache module, I'm not even sure what my shebang should look like. Any ideas?
The CLI version of PHP had been part of the default installation since 4.3 and has to be explicitly turned off when PHP is being built. If you have access to the command line try
$ php -v
If you don't get a command not found error then you should be ready to go.
To actually run a php file from the command line do this:
$ php -f file.php
If it's just an Apache module, I don't think you can do it… At least, not without using a script like this:
$ cat run_php_with_apache
#!/bin/sh
cp "$1" /var/www/
curl "http://localhost/`basename "$1"`"
rm "/var/www/`basename "$1"`"

Categories