I have created a logic that look seems fine if I run that via controller file. But I am getting an error while running via cron (checked via log file), using magento2 cron process.


Is there any way that I can run this file directly via browser to debug the things?

Please reply ASAP!

  • Might be a permission issue. Are you running cron with server owner permissions?
    – Lez
    Dec 28, 2017 at 13:08
  • Brother, Okay, but "Is there any way that I can run cron file via browser ?"
    – Atul
    Dec 28, 2017 at 14:28

1 Answer 1


To run a php file in a browser from your module, you need to temporarily disable the .htaccess file in your app folder.

For example, rename it to .htaccess2.

Then you can browse the file in your browser like this:


Just don't forget to return the .htaccess file back to normal after debugging.


You can test functions by calling your file through browser like this: http://domain.com/path/to/cron/file/?function=testFunction

And in your cron php file, you can make a switch statement to call your functions like this:

switch($_GET['function']) {
    case 'testFunction':

function testFunction() {
    echo 'test';
    // your cron logic

... //other functions

Although for debugging purposes, maybe you could use Magento's log functions to debug your problem.

See this question for more info: Magento 2: Replacement for Mage::log method?.

  • its showing blank page .....
    – Atul
    Jan 3, 2018 at 12:59
  • @Atul that means you execute the php file, but don't print/echo anything. Try echoing something in your file.
    – Lez
    Jan 3, 2018 at 13:47
  • in execute function i applied "echo 'helloooo'; "...Is it ryt ?
    – Atul
    Jan 4, 2018 at 7:37
  • Check my edit for more info.
    – Lez
    Jan 4, 2018 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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