如何使用php设置crontab? [英] How to set a crontab using php?

查看:305
本文介绍了如何使用php设置crontab?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一个php脚本设置一个crontab。我知道它可以通过

i need to set a crontab from a php script. i know that it can be set by

系统(echo'* * * * * echo \ Hello world\'>> cron.crontab);
system(crontab cron.crontab); //cron.crontab是crontab的文件名

cron.crontab文件已创建在根目录,但crontab不能按预期工作!当我尝试以下命令,它说没有crontab设置!

"cron.crontab" file is created in root directory, but crontab is not working as expected! when i try the following command, it says that no crontab is set!


crontab -l <​​/ code>

crontab -l

我想我错过了一些东西。我使用yii框架。有没有一个扩展来处理cron在yii框架?有没有其他方法来做呢?请帮帮我。感谢。

i think i am missing something. i am using yii framework. is there an extension to handle cron in yii framework? is there any other way to do it? Please help me. Thanks.

推荐答案

您作为同一用户运行 crontab -l <​​/ code>作为web服务器正在运行?否则你不会看到它的cronjobs。

Are you running crontab -l as the same user as the web server is running under? Otherwise you won't see its cronjobs.

这篇关于如何使用php设置crontab?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆