1、tp5命令
- application/模塊/command/Test.php
namespace app\admin\command;
use app\admin\model\User;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
/**
* Created by PhpStorm.
* User: win7
* Date: 2018/9/19
* Time: 10:46
*/
class Produce extends Command
{
protected function configure(){
$this->setName('Test')->setDescription("計劃任務 Test");
}
protected function execute(Input $input, Output $output){
$output->writeln('Date Crontab job start...');
/*** 這里寫計劃任務串列集 START ***/
$this->test();
/*** 這里寫計劃任務串列集 END ***/
$output->writeln('Date Crontab job end...');
}
private function test(){
// $user = User::find();
echo "test\r\n";
}
}
- application/command.php
return ['app\admin\command\Test'];
- 運行命令
php think Test
2、bat檔案
@echo offcd F:\webF:php think Test
3、windows定時任務
開始>附件》系統工具》任務計劃程式
創建基本任務
問題
-
pdoException
database.php檔案 hostname 是127.0.0.1 改為資料庫服務器ip
-
could not open input file:think
bat 檔案中 加盤符 F:
文章轉自:
https://blog.csdn.net/aawuwuwuxx/article/details/82781858
更多參考:
https://www.jianshu.com/p/d99b239c86d2
https://www.cnblogs.com/whoknows/articles/2228577.html
https://www.cnblogs.com/seizemiss/p/9467558.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/24465.html
標籤:PHP
