如何将Linux-CronTab定时执行ThinkPHP命令行模式转化为高效长尾关键词策略?
- 内容介绍
- 文章标签
- 相关推荐
本文共计232个文字,预计阅读时间需要1分钟。
php
use think\console\Command;use think\console\Input;use think\console\Output;
class Test extends Command{ protected function configure() { // 可选:设置名称与描述 $this->setName('this is name'); }}
test.phpnamespace app\appname\command; use think\console\Command; use think\console\Input; use think\console\Output; class Test extends Command { protected function configure() { //可选 设置名称与描述 $this -> setName('this is name') -> setDescription('this is description'); } //具体的执行方法 protected function execute(Input $input, Output $output) { //这里操作具体的实现方法 echo "Hello World!"; } } Linux
yum -y install vixie-cron yum -y install crontab //cron 是 linux 的内置服务,但它不自动起来 //可以用以下的方法启动、关闭这个服务: service crond start //启动服务 service crond stop //关闭服务 service crond restart //重启服务 service crond reload //重新载入配置 service crond status //查看crontab服务状态 //在CentOS系统中加入开机自动启动: chkconfig --level 345 crond on crond
crond -e 0 4 * * * /usr/local/php71/bin/php /data/wwwroot/www.xxx.com/wuye/think test //每天4点0分执行这个test命令
本文共计232个文字,预计阅读时间需要1分钟。
php
use think\console\Command;use think\console\Input;use think\console\Output;
class Test extends Command{ protected function configure() { // 可选:设置名称与描述 $this->setName('this is name'); }}
test.phpnamespace app\appname\command; use think\console\Command; use think\console\Input; use think\console\Output; class Test extends Command { protected function configure() { //可选 设置名称与描述 $this -> setName('this is name') -> setDescription('this is description'); } //具体的执行方法 protected function execute(Input $input, Output $output) { //这里操作具体的实现方法 echo "Hello World!"; } } Linux
yum -y install vixie-cron yum -y install crontab //cron 是 linux 的内置服务,但它不自动起来 //可以用以下的方法启动、关闭这个服务: service crond start //启动服务 service crond stop //关闭服务 service crond restart //重启服务 service crond reload //重新载入配置 service crond status //查看crontab服务状态 //在CentOS系统中加入开机自动启动: chkconfig --level 345 crond on crond
crond -e 0 4 * * * /usr/local/php71/bin/php /data/wwwroot/www.xxx.com/wuye/think test //每天4点0分执行这个test命令

