Home PHP Framework YII How to solve the problem of unsuccessful scheduled tasks in yii2

How to solve the problem of unsuccessful scheduled tasks in yii2

Nov 06, 2019 pm 04:18 PM
yii2 Scheduled Tasks

How to solve the problem of unsuccessful scheduled tasks in yii2

How to solve the problem if the yii2 scheduled task is unsuccessful

I wrote a script using the Yii2 console and executed it on the command line All OK. It was put into cron and executed on time, but the execution effect was wrong, and the console script execution result was wrong.

After checking, it is due to the php path problem of the yii script (yii under the root directory)

You need to replace the first line of the following code, php, with the path on your server

#!/usr/bin/env php
<?php
/**
 * Yii console bootstrap file.
 *
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */defined(&#39;YII_DEBUG&#39;) or define(&#39;YII_DEBUG&#39;, true);
defined(&#39;YII_ENV&#39;) or define(&#39;YII_ENV&#39;, &#39;dev&#39;);
require(__DIR__ . &#39;/vendor/autoload.php&#39;);
require(__DIR__ . &#39;/vendor/yiisoft/yii2/Yii.php&#39;);
require(__DIR__ . &#39;/common/config/bootstrap.php&#39;);
require(__DIR__ . &#39;/console/config/bootstrap.php&#39;);
$config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . &#39;/common/config/main.php&#39;),
    require(__DIR__ . &#39;/common/config/main-local.php&#39;),
    require(__DIR__ . &#39;/console/config/main.php&#39;),
    require(__DIR__ . &#39;/console/config/main-local.php&#39;)
);
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
Copy after login

Or add a soft connection to the PHP executable file on the server

ln -s /usr/local/php/bin/php /usr/local/bin/php

ln - s The absolute path where the current file absolute path is to be placed

Recommended: "YII Tutorial"

The above is the detailed content of How to solve the problem of unsuccessful scheduled tasks in yii2. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to remove jquery in yii2 How to remove jquery in yii2 Feb 17, 2023 am 09:55 AM

How to remove jquery from yii2: 1. Edit the AppAsset.php file and comment out the "yii\web\YiiAsset" value in the variable $depends; 2. Edit the main.php file and add the configuration "'yii" under the field "components" \web\JqueryAsset' => ['js' => [],'sourcePath' => null,]," to remove the jquery script.

Schedule tasks to specify time points and execute one-time tasks that depend on the atd service Schedule tasks to specify time points and execute one-time tasks that depend on the atd service Mar 11, 2024 am 09:07 AM

The scheduled task is scheduled to execute atat at a specified time point at a time, and the one-time task depends on the atd service. It needs to be started to realize the at task. The at queue is stored in the /var/spool/at directory -V: Display version information -l: List the specified queue Jobs waiting to be run; equivalent to atq-d: delete the specified job; equivalent to atrm-c: view specific job tasks [root@localhost~]#systemctlstartatd[root@localhost~]#systemctlenableatd[root@localhost~]# atnow+1minat>useraddxwzat>#

A few selected CTF exercises will help you learn the yii2 framework! A few selected CTF exercises will help you learn the yii2 framework! Feb 23, 2022 am 10:33 AM

This article will introduce you to the yii2 framework, share a few CTF exercises, and use them to learn the yii2 framework. I hope it will be helpful to everyone.

What is the method to set the scheduled power on and off of Windows 7? What is the method to set the scheduled power on and off of Windows 7? Jul 10, 2023 pm 09:49 PM

Most users don’t know what the scheduled power on and off setting method for windows 7 is. Specifically, win7 can be set to automatically shut down, but users don’t know how to set it up. In fact, it can be set by entering a simple code, and you need to use cmd to set it up. The following is an introduction to the actual Windows 7 timer power on and off setting method. Users can refer to it and set it up, which is very simple. What is the method to set the timer on and off of Windows 7? 1. Set automatic shutdown. In fact, it can only be done from within the capabilities of the system itself, i.e. entering the shutdown command in the action box. Open the menu bar and click Action. If not, just press the shortcut key to open it, win+r to open it. 2. For example, if we want to turn off the power after three hours

Timed task and planned task technology in PHP Timed task and planned task technology in PHP May 11, 2023 pm 04:13 PM

With the rapid development of the Internet, more and more websites and applications need to perform some scheduled tasks and planned tasks in the background, such as data cleaning, backup, statistical analysis, etc. As a popular web development language, PHP also provides corresponding scheduled task and planned task technology. This article will introduce the scheduled task and planned task technology in PHP in detail. 1. Concept and usage scenarios of scheduled tasks 1.1 Concept Scheduled tasks refer to automatically executing some specified tasks or operations within a specified time point or time interval. 1.2 make

How to install Redis extension using YII2 framework How to install Redis extension using YII2 framework May 26, 2023 pm 06:41 PM

1. You need to download the windows version of the master branch of yii2-redis with composer 2. Unzip and copy it to vendor/yiisoft 3. Add 'yiisoft/yii2-redis'=>array('name'=>'yiisoft to extensions.php under yiisoft /yii2-redis','version'=>'2.0.

Timed task and planned task management with PHP and mini-programs Timed task and planned task management with PHP and mini-programs Jul 04, 2023 am 10:05 AM

Timing tasks and planned task management of PHP and small programs With the continuous development of Internet technology, many websites and applications need to perform certain tasks regularly, such as data cleaning, data analysis, data synchronization, etc. In PHP and small program development, how to manage scheduled tasks and planned tasks is an important topic. This article will introduce how to use PHP and applets to manage timed tasks and planned tasks, and give corresponding code examples. Scheduled task management in PHP In PHP, we can use Cron to manage scheduled tasks.

How to implement scheduled tasks and scheduled tasks through the Webman framework? How to implement scheduled tasks and scheduled tasks through the Webman framework? Jul 08, 2023 am 11:43 AM

How to implement scheduled tasks and scheduled tasks through the Webman framework? Webman is a lightweight web framework developed based on Go language. It provides a simple way to implement scheduled tasks and planned tasks. This article will introduce how to use the Webman framework to implement timed tasks and scheduled tasks, and provide corresponding code examples. Before using the Webman framework, you need to install Webman first. Webman can be installed with the following command: gogetgithub.com/he

See all articles