# tp5任务命令
![](https://img.kancloud.cn/35/9e/359ea9794b5c37200f2ee80a26989345_978x483.png)
## 执行规则
```
~~~
<?php
namespace app\common\command;
// +----------------------------------------------------------------------
// | 社群团购电商Saas系统 [ E-commerce Froup Purchase Saas System ]
// +----------------------------------------------------------------------
// | Copyright (c) 2022 https://www.bancou.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 郑坦强 @希泛科技 <https://www.bancou.com>
// +----------------------------------------------------------------------
use think\Config;
use think\console\input\Option;
class TestJob extends \think\console\Command
{
protected function configure()
{
$site = Config::get('site');
$this->setName("TestJobTp5")
->addOption("param_name",'',Option::VALUE_OPTIONAL,'指定ID后数据')
->addOption("param_age",'',Option::VALUE_OPTIONAL,'指定ID后数据')
->setDescription('这个是测试tp5的异步任务');
}
protected function execute(\think\console\Input $input, \think\console\Output $output)
{
$param_name = $input->getOption("param_name");
$param_age = $input->getOption("param_age");
$output->writeln(sprintf("---成功名称:%s,年纪:%s,",$param_name,$param_age));
$output->writeln("延迟2秒执行....");
//parent::execute($input, $output); // TODO: Change the autogenerated stub
}
}
~~~
```
![](https://img.kancloud.cn/ab/e9/abe9c44a16ae69bcfd6d9d0fd8300c59_1340x783.png)
## 命令行执行命令
```
php think TestJobTp5 --param_name=zheng --param_age=15
```
![](https://img.kancloud.cn/07/df/07df5cf123ab7afb91814ba036939598_1126x239.png)