Skip to content

Log file not available in after() function #104

@eradin

Description

@eradin

Crunz version: 3.7.0

PHP version: 8.1

Operating system type and version: Ubuntu

Description
I have a backup task that looks like so:

// backup task
echo "running task: Backing up database\n";
$task = $schedule->run("$jobs/mysqlbackup3.sh");
$task->daily()->at('01:30')
    ->description('Backing up database')
    ->sendOutputTo("$logs/mysqlbackup3.log")
    ->after(function () {
        global $logs;
        
        // email log to us
        mail('eric@inc.com', 'MySql Backup', file_get_contents("$logs/mysqlbackup3.log"), [], '-fcron@inc.com');
    });

It works properly but the body of the email is always blank. I can see the file on the server with the proper contents so it gets created. I suspect the log file has not been written to disk yet at the time of the after() call. Perhaps there is another way to mail me the output? I don't think it's related to the job being a shell script.

How to reproduce
see above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions