when i run the Tasks :
* * * * * /bin/bash /home/soulexhi/public_html/scheduler_cron.sh --mode always
* * * * * /bin/bash /home/soulexhi/public_html/scheduler_cron.sh --mode default
As per Cron Scheduler tells me to i am getting this error message via Email
HELP!!
Content-type: text/html;
<br />
<b>Warning</b>: require_once(/abstract.php): failed to open stream: No such file or directory in <b>/home/soulexhi/public_html/shell/scheduler.php</b> on line <b>3</b><br /> <br /> <b>Fatal error</b>: require_once(): Failed opening required '/abstract.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in <b>/home/soulexhi/public_html/shell/scheduler.php</b> on line <b>3</b><br />
At the beginning of the file 'magento_root/shell/scheduler.php' there is a require_once that I changed to the following to:
if (!empty($_SERVER['SCRIPT_NAME']))
require_once dirname($_SERVER['SCRIPT_NAME']) . DIRECTORY_SEPARATOR . 'abstract.php';
else
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'abstract.php';
but it did not work. Does anyone have any idea?
Solved: It was the PHP version of Cron Jobs.
The PHP version was set correctly for the site which is why it was working; however Cron Jobs was running at server native PHP 5.3 which is why I was getting the errors only when running Cron. I updated to version 5.5.
Changed Cron command:
php /home/mydomainname/public_html/cron.php
to
php55 /home/mydomainname/public_html/cron.php
in cron.php
$isShellDisabled = (stripos(PHP_OS, 'win') === false) ? $isShellDisabled : true;
After this line, add:
$isShellDisabled = true;
Related
Little help or guidance. Server is CentOS 7 - with WHM/CPanel installed.
Command:
$(which php) $(which wp) core update --require=/opt/wp-cli-pre.php --path=/home/USER/public_html/
The contents of /opt/wp-cli-pre.php
<?php
if(!defined('STDIN')) define('STDIN', fopen('php://stdin', 'r'));
if(!defined('STDOUT')) define('STDOUT', fopen('php://stdout', 'w'));
if(!defined('STDERR')) define('STDERR', fopen('php://stderr', 'w'));
Works as expected from the command line, but if from cron job, I get:
PHP Warning: Use of undefined constant STDOUT - assumed 'STDOUT' (this will throw an Error in a future version of PHP) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 1057
output of "which php"
/usr/local/bin/php
output of "which wp"
/usr/local/bin/wp
I have installed the latest WP-CLI from https://wp-cli.org/
At long last, I have found the solution.
When the CRON runs a PHP script like this: */5 * * * * php /path/to/script.php
The SAPI name is: cgi-fcgi (on a WHM/CPanel install on CentOS)
It cannot find the CLI version setup by CPanel at /usr/local/bin/php as the $PATH var is just: /usr/bin:/bin
So, the solution is to not depend on the system environment to determine the PHP you want. But to set that directly.
Like this: */5 * * * * /usr/local/bin/php /path/to/script.php
It was always my assumption that if a CRON was setup in ROOT's crontab, it would inherit ROOT's environment. This apparently is not the case.
You should take a look at the following post.
https://forums.cpanel.net/threads/users-cannot-use-wp-cli-in-cron.643293/
I'm trying to create a Scheduler in Laravel 5.8 on my localhost, but it only runs when I use the following command.
php /opt/lampp/htdocs/my_project/artisan schedule:run >> /dev/null 2>&1
php artisan schedule:run
and not runs every minute as i defined
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
$good = new Grocery();
$good->name = 'good';
$good->type = 'type';
$good->price = '222';
$good->save();
})->everyMinute();
}
Data is stored in the database, but I should run the command every time.
Nothing is unique in the database.
Your schedule:run needs to be added to your cronjob.
This can be done by typing crontab -e. Once done you should enter the command to be executed every minute:
* * * * * php /opt/lampp/htdocs/my_project/artisan schedule:run >> /dev/null 2>&1
This will set the command to run every minute. Your application is then responsible for seeing if your scheduled command should run.
I have installed Magento 2 using the instructions in the development documentation.
Everything works fine except for the cron jobs that the admin system continually says are not working.
I followed the development docs and added the following lines into my crontabs file.
*/1 * * * * php -c /etc/php5/cli/apache2 /var/www/html/magento2/bin/magento cron:run
*/1 * * * * php -c /etc/php5/cli/apache2 /var/www/html/magento2/update/cron.php
*/1 * * * * php -c /etc/php5/cli/apache2 /var/www/html/magento2/bin/magento setup:cron:run
I have manually run the first and third command and they run without error. The second line I am having problems with. /var/www/html/magento2/update/cron.php does not exist. In fact the update directory does not exist.
Where does the update directory come from, and why don't I have it?
update/cron.php file is in the magento2-community-edition package:
https://github.com/magento/magento2-community-edition/blob/2.0.0/update/cron.php
I am writing a plugin to check authentication to a https site and then search for a text in the response html,body to confirm successful login. I have created the following plugin
#!/bin/bash
add_uri='--no-check-certificate https://'
end_uri='/'
result=$(wget -O- $add_uri$1$end_uri --post-data=$2)
flag=`echo $result|awk '{print match($0,"QC Domain")}'`;
echo $flag
echo "Nagios refreshes properly1"
if [[ $flag -gt 0 ]] ; then
echo 'ALL SEEMS FINE!!'
exit 0
else
echo 'Some Problem'
exit 2
fi;
When I execute this plugin directly from command line
./check_nhttps <url here> '<very long post data with credential information>'
The plugin works as expected(For both + & - test cases) and there seems to be no issues.
But when the plugin runs from Nagios,
check_command check_nhttps! <url here> '<very long post data with credential information>'
It always shows critical error(Prints else condition text "Some Problem" too).
P.S : Tried sending the post data with double quotes also.
Please help!!!
I'd think its very probable that your post data contains some characters that confuse nagios, maybe a space, or even a !. Better put the post data into some file and use --post-file. Also, you might insert echo "$2" > /tmp/this_is_my_post_data_when_executed_by_nagios into your script and check if the post data is ok.
How run zend framework action (inside index controller) by cron every 12 hours?
The case:
I have basic(no modules) zend project (1.11) that created by zf tool.
Inside main IndexController exist cronAction() - url http://mydomain/index/cron.
Need to run cronAction() once per 12 hours by cron.
Thanks
Find the crontab file and add this line:
0 0,12 * * * curl --silent --compressed http://mydomain/index/cron
You can also do it with other tools, such as lynx or wget, not necassarily curl - the above is just an example.
I know I am bit late but I would like to leave another solution, maybe it help other people, you could run the file in cron if you have your business rule inside model
By creating a file in the public folder with the content below. Ex.: cron.php
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();
$model = new Application_Model_Name();
$model->runTask();
Then add a cron tab entry
0 0,12 * * * php /path/to/your/project/cron.php
It should work better than first answer since you will run using PHP CLI then you won't have execution time limit of php script, in case of your script takes more than one minute and you don't need network connection to run that cron job
In Zend Framework 2 You can run a cron job using console routes. Take a look at the example posted here: http://collabedit.com/58v4v