<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="default">
        <job name="test_product_import" instance="Test\ImportExport\Cron\ProductImport" method="execute">
            <schedule>* * * * *</schedule>

Php File that gets called by cron:


namespace Test\ImportExport\Cron;

class ProductImport
    protected $trace;

    public function __construct(
        \Test\Core\Model\Trace $trace
        $this->trace = $trace;

    public function execute()

Error message in cron_schedule table :

Warning: fopen(app/code/Test/Trace.txt): failed to open stream: No such file or directory in /var/www/www.example.com/app/code/Test/Core/Model/Trace.php on line 12

On line 12 in this file:

$tracelog = fopen("app/code/Test/Trace.txt", "a") or die("Unable to open file!");

In SSH I executed

php magento cron:run

and I got the error. Since I assume a permission problem I tried

sudo -u www-data php magento cron:run

same issue. What's wrong?

1 Answer 1


I was able to solve it.

$tracelog = fopen("app/code/Test/Trace.txt", "a") or die("Unable to open file!");

I had to specify the absolute path to the file instead of the relative as shown above.

Your Answer

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

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