Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

php - Cron Job $_SERVER issue

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...