[TYPO3-dev] HowTo: Running a cronscript using TYPO3 with CLI
Ansgar Brauner
ansgarb at gmail.com
Wed Mar 5 17:25:26 CET 2008
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
More information about the TYPO3-dev
mailing list