开发者

Setting up Dreamhost Cron job to simply execute URL

开发者 https://www.devze.com 2023-01-17 16:48 出处:网络
Just when I thought I was understanding cron jobs, I realize I\'m still not understanding. I\'m trying to set up a cron job through Dreamhost to ping a URL once an hour. This URL when visited performs

Just when I thought I was understanding cron jobs, I realize I'm still not understanding. I'm trying to set up a cron job through Dreamhost to ping a URL once an hour. This URL when visited performs a small(ish) query and updates the database.

A few examples I've tried which haven't seemed to of worked:

wget -O /dev/null http://www.domain开发者_C百科.com/index.php?ACT=25&profile_id=1

and

wget -q http://www.domain.com/index.php?ACT=25&profile_id=1

The correct domain was inserted into the URL of course.

So, what am I missing? How could I execute a URL via a Cronjob?


One thing, are you escaping your url?

Try with:

wget -O /dev/null "http://www.domain.com/index.php?ACT=25&profile_id=1"

Having an ampersand in the URL usually leads to strange behaviour (process going background and ignoring the rest of the URL, etc).


I just had the same exact problem, and I found that actually two solutions work. One is as Victor Pimentel suggested: enclosing the url with " and the second option is to escape the & character in the cronjob like this: \&, so in your case the statement would look like this:

wget -q http://www.domain.com/index.php?ACT=25\&profile_id=1

or

wget -q "http://www.domain.com/index.php?ACT=25&profile_id=1"


Putting the following on the Dreamhost control panel\goodies\cron seems to work for me

wget -qO /dev/null http://domain/cron.php


links -dump http://Txx-S.com/php/test1.php

Worked much better than wget. It echoes the outputs of the php script into the email without all the junk that wget provides. Took awhile to get here, but it IS in the Dreamhost documentation. Don't need all the home/user stuff and the headache of placing all the php's under different users... IMHO. Pete

0

精彩评论

暂无评论...
验证码 换一张
取 消