Paolito75
Paolito75

Reputation: 568

TYPO3 scheduler task - strange behavior

I'm using TYPO3 6.2 and I created a custom extension with Extbase and Fluid. I made a custom task in order to execute it every hour in the TYPO3 scheduler module. Below what it looks like :

<?php

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Backend\Utility\BackendUtility;

class ImportCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController {

    public function importCommand() {

    // some code

    }

}

?>

It seems to work fine, but the behavior is weird :

[scheduler]: Removing logged execution, assuming that the process is dead. Execution of 'TYPO3\CMS\Extbase\Scheduler\Task' (UID: 5) was started at 2018-06-10 16:40:00

Then, I have to stop the task myself in the scheduler. According to the documentation, methods inside the class don't need to return true or false. So, why the task isn't successfull when launched by the scheduler ?

Upvotes: 1

Views: 1459

Answers (2)

Heinz Schilling
Heinz Schilling

Reputation: 2252

I made a scheduler task like this

<?php
namespace Vendor\Extensionname\Task;

/***************************************************************
 *  Copyright notice
 *
 *  All rights reserved
 *
 *  ...
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/


/**
 * My scheduler task
 *
 */
class MyTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask  {


    /**
     * Execute, called by scheduler.
     *
     * @return bool TRUE if task run was successful
     */
    public function execute() {

        \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(
            '[Vendor\\Extensionname\\Task\\MyTask]: Task run sucessfully', 'scheduler', 2);
        }
        return true;
    }


}

Upvotes: 1

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10791

there are some differences between the scheduler task starting methods:

  • scheduled by cron:
    it's CLI PHP which might be another version, at least another configuration than the PHP started by webserver (e.g. no time limit!), in TYPO3 it is executed with the special cli-user.

  • started in the BE:
    this is started in the webserver context: (normaly) you have a time limit, the current TYPO3-BE user executes the task.

Upvotes: 0

Related Questions