Cron Job $ _SERVER问题 [英] Cron Job $_SERVER issue

查看:176
本文介绍了Cron Job $ _SERVER问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行cron作业。

I want to run a cron job. My application is developed in PHP and Mysql.

在浏览器中,如果我在编码中使用 $ _ SERVER [HTTP_HOST] 它工作正常。但是如果我在cron工作中使用相同的东西,它会给出错误。

In browser if i use $_SERVER[HTTP_HOST] in coding, it works fine. But if I use the same thing in cron job it is giving errors.

任何机构都可以给出建议来解决这个问题。

Can any body give suggestion to fix this?

推荐答案

$ _ SERVER ['HTTP_HOST'] 未填充从cronjob运行时, HTTP。

$_SERVER['HTTP_HOST'] is not populated when running it from a cronjob, the file is not accessed via HTTP.

您必须硬编码主机或通过命令行参数传递它,并通过 $ _ SERVER ['argv' ] 数组。

You will either have to hardcode the Host or pass it via a command line argument and access it via the $_SERVER['argv'] array.

这篇关于Cron Job $ _SERVER问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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