1

Running Magento 2 on my local WAMP Windows 10

I'm following below 2 Tutorials

[1] https://www.atwix.com/magento-2/setting-up-cron-jobs/

namespace Custom\Module\Cron;

class MyCronTask {

    public function execute() {
        /**
         *  Do some cool stuff here
         */
        echo "hi";
        exit;

        return $this;
    }
}

When i run through command line it' not displaying message "Hi".

php bin/magento cron:run --group="my_cronjobs"
Ran jobs by schedule.

It only says "Ran jobs by schedule."

[2] http://inchoo.net/magento-2/running-cron-jobs-in-magento-2/

When i run

php bin/magento setup:cron:run
setup-cron: Please check var/log/update.log for execution summary.

In update.log it keep says

[2016-09-26 09:59:38] setup-cron.ERROR: Your current PHP memory limit is 80000M. Magento 2 requires it to be set to 756M or more. As a user with root privileges, edit your php.ini file to increase memory_limit. (The command php --ini tells you where it is located.) After that, restart your web server and try again. [] []

I already increase memory_limit in php.ini up to 80000M. Cleared cache as well.

0

Finally got the solution

Thanks for help from atwix.com.

https://www.atwix.com/magento-2/logging-system/

namespace Custom\Module\Cron;

class MyCronTask {

    protected $_logger;

    public function __construct(\Psr\Log\LoggerInterface $logger) {
        $this->_logger = $logger;
    }

    public function execute() {
        $this->_logger->info("test-cron-message");
        $this->_logger->debug("test-cron-message");
        return $this;
    }
}

After running below commands

php bin/magento setup:cron:run
php bin/magento cron:run --group="my_cronjobs"
Ran jobs by schedule.

It will save in var/system.log & var/debug.log, where you can see your logged data.

For memory_limit set it to 800M in php.ini & it's working fine:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.