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

Categories

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

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

1 Answer

$_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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...