suchen
Heimphp教程php手册linux下crontab定时PHP计划任务失败原因分析

linux下crontab定时PHP计划任务失败原因分析

Jun 13, 2016 am 09:30 AM
crontablinuxphpRunter任务原因分析失败定时计划

linux下crontab定时PHP计划任务失败原因分析

linux下使用crontab实现定时PHP计划任务失败的原因。

很多人在linux下使用crontab实现PHP执行定时任务却未能成功,不能生成缓存。本文就linux下使用crontab实现定时PHP计划任务失败的原因做一分析。

一般linux定时执行php代码例如:
*/5 * * * * /usr/local/php/bin/php /home/wwwroot/1.php
其实这样是可以执行php代码的。
但是为什么很多朋友在1.php写的生成一个缓存文件没有生成呢?
这个要涉及到crontab执行php的相对路径问题.

注意,在执行文件中,有包含文件的,如:
include_once'./mysql.php';

当php代码中,用的是相对路径时,只有进入到那个目录下,www.jbxue.com
然后执行/usr/local/php/bin/php /home/wwwroot/1.php 才能引用mysql.php生效。
解决方法:
*/10 * * * * cd /home/wwwroot && /usr/local/php/bin/php /home/wwwroot/1.php
同时也这样缓存才能生成在 /home/wwwroot。此处需要特别注意!
这是大部分写的所谓linux定时执行php没有提到的,也最容易产生误区的。
当然方法还有很多,还可以设置环境变量之类的。这个只是一个简单的方法。

Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. So reparieren Sie Audio, wenn Sie niemanden hören können
3 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Wie man alles in Myrise freischaltet
4 Wochen vorBy尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung

WebStorm-Mac-Version

WebStorm-Mac-Version

Nützliche JavaScript-Entwicklungstools

MantisBT

MantisBT

Mantis ist ein einfach zu implementierendes webbasiertes Tool zur Fehlerverfolgung, das die Fehlerverfolgung von Produkten unterstützen soll. Es erfordert PHP, MySQL und einen Webserver. Schauen Sie sich unsere Demo- und Hosting-Services an.

SublimeText3 Linux neue Version

SublimeText3 Linux neue Version

SublimeText3 Linux neueste Version

Notepad++7.3.1

Notepad++7.3.1

Einfach zu bedienender und kostenloser Code-Editor