[TYPO3-dev] HowTo: Running a cronscript using TYPO3 with CLI

Ingmar Schlecht ingmar at typo3.org
Wed Mar 5 17:40:16 CET 2008


I have added a link to this thread to the 
http://wiki.typo3.org/index.php/Pending_Documentation#doc_core_api wiki 
page, so we're reminded of updating the documentation about 
cli_dispatch.phpsh in TYPO3 Core API.

cheers
Ingmar

Ansgar Brauner schrieb:
> Steffen Kamper schrieb:
>> Hi Steffen,
>>
>> it's very easy, here is a very very basic one
>> ===============================
>> create BE user _cli_cronjob
>>
>> in ext_localconf.php:
>> //register key for cli
>> $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys']['mycliscript']= 
>> array('EXT:myext/croncli.php','_CLI_cronjob');
>>
>> the croncli.php:
>>
>> if (!defined('TYPO3_cliMode')) die('You cannot run this script directly!');
>>
>> require_once(PATH_t3lib.'class.t3lib_cli.php');
>>
>> class tx_myjobs extends t3lib_cli {
>>
>>  function main($argv) {
>>   $args = $this->cli_getArgArray('-f',$argv);
>>   print_r($args);
>>  }
>> }
>>
>>  // Call the functionality
>> $myObj = t3lib_div::makeInstance('tx_myjobs');
>> $myObj->main($_SERVER["argv"]);
>> ===============================
>>
>> then call it on console:
>> /var/www/.../typo3/cli_dispatch.phpsh mycliscript -f hello
>>
>> works.
> 
> 
> Guys, you made my day!!!
> 
> After searching half of the day for information about the CLI i found
> your thread with this easy but excellent example.
> 
> Now i can start coding my scripts.
> 
> Thanks a lot!
> 
> regards
> 
> Ansgar


-- 
Ingmar Schlecht
TYPO3 Association Active Member




More information about the TYPO3-dev mailing list