如何在Ubuntu中使用Cronjob运行CodeIgniter PHP文件?

发布于 2025-02-08 16:50:38 字数 208 浏览 1 评论 0原文

因此,我在codeigniter中具有此PHP功能路径,我试图通过Ubuntu中的Cron作业运行。但是无论我尝试过什么,它都无法正常工作。到目前为止,我尝试过的命令

* * * * * /usr/bin/php http://localhost/QAPIv2/updateTestData

,但没有执行。我正在使用Codeigniter

So i have this php function path in codeigniter which I am trying to run through cron job in ubuntu. But whatever I have tried it is not working. The command I have tried so far

* * * * * /usr/bin/php http://localhost/QAPIv2/updateTestData

But it is not executing. I am using codeigniter

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

终止放荡 2025-02-15 16:50:38

要详细说明Rohan的答案,您可以运行诸如php index.php控制器函数之类的功能。因此,例如,要在每个星期二上午8:31运行您的脚本,您的crontab条目应该看起来像:

31 08 * * 2 cd /path/to/codeigniter; /usr/bin/php index.php QAPIv2 updateTestData;

To elaborate on Rohan's answer, you run the functions like php index.php controller function. So, for example, to run your script every Tuesday at 8:31AM, your crontab entry should look like :

31 08 * * 2 cd /path/to/codeigniter; /usr/bin/php index.php QAPIv2 updateTestData;
恬淡成诗 2025-02-15 16:50:38

尝试以下操作:

*/1 * * * * /usr/bin/php /var/www/html/YOUR PROJECT FOLDER NAME/index.php YOUR FUNCTION NAME > /dev/null 2>&1

第一个数字是cron.in功能名称的时间,您应该给要加载在Cron中的控制器函数名称。

Try this:

*/1 * * * * /usr/bin/php /var/www/html/YOUR PROJECT FOLDER NAME/index.php YOUR FUNCTION NAME > /dev/null 2>&1

First number is time for cron.In function name you should give the controller function name which you want to load in cron.

泪意 2025-02-15 16:50:38

请从命令行调用功能。

$ cd /path/to/project;
$ php index.php controller function

请根据您的代码更改控制器和功能。

Please call the function from the command line.

$ cd /path/to/project;
$ php index.php controller function

Please change the controller and function according to your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文