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

Steffen Kamper steffen at sk-typo3.de
Fri Jan 4 09:24:08 CET 2008


"Steffen Ritter" <info at rs-websystems.de> schrieb im Newsbeitrag 
news:mailman.1.1199432609.25560.typo3-dev at lists.netfielders.de...
> 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.
>>
>> vg  Steffen
>>
>> "Steffen Ritter" <info at rs-websystems.de> schrieb im Newsbeitrag 
>> news:mailman.1.1199387764.1420.typo3-dev at lists.netfielders.de...
>>> Steffen Kamper schrieb:
>>>> "Ernesto Baschny [cron IT]" <ernst at cron-it.de> schrieb im Newsbeitrag 
>>>> news:mailman.1.1199376508.29585.typo3-dev at lists.netfielders.de...
>>>>> Steffen Kamper wrote: on 03.01.2008 16:54:
>>>>>
>>>>>> So little additional question, how can I access commandline 
>>>>>> parameters? e.g.
>>>>>> i want to start my script this way
>>>>>> /abspath/typo3/cli_dispatch.phpsh mysscript -f 100
>>>>> You pass $_SERVER['argv'] to your main() method of your class and it 
>>>>> can
>>>>> handle the command line the way it wishes. AFAIK we don't have any
>>>>> getopt()-like functionality in TYPO3-core, so you have to do it your 
>>>>> own
>>>>> way.
>>>>>
>>>>> Cheers,
>>>>> Ernesto
>>>> I found something usable:
>>>> t3lib_cli::cli_getArgArray($option,$argv)
>>>>
>>>> i will test a bit with this and may be make a demo-ext, thx for your 
>>>> hints.
>>>>
>>>> vg  Steffen
>>> Fascinated by your discussion i tried the hole afternoon to create an 
>>> own CLI Script using the cli_dispath.php.
>>> Against the information in 
>>> typo3/sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt it does not 
>>> work as written in this Document. At the moment I'm going throug all 
>>> files which are included while CLI and checking what happens.
>>> When finished I will report what I had to do, and publish some kind of 
>>> "Howto"...
>>>
>>> mfG
>>>
>>> Steffen
>>>
>>
>>
> Okay, this looks quite good. The HowTo tells to extend the lowlevel_core, 
> which did not work. The rest of my work is like your explenaiton. So i 
> gonna change my classes, and will tell, what happened.
>
> PRobably there should be a Howto on typo3.org or a possibility to start 
> CLI Interface in Kickstarter.
> If I gonna publish one or both of this, how should I talk to for use?
>
> mfG
>
> Steffen

for changing Kickstarter or Documentation make a BT-entry and a RFC in core 
list.

vg  Steffen 






More information about the TYPO3-dev mailing list