PDA

View Full Version : cron job to access web site's domain



optical
07-28-2007, 02:09 PM
Hello

I need to call cron.php with lynx or wget from its web site's domain and not directly from localhost i.e.
NOT
/usr/bin/lynx -source /home/USERNAME/public_html/cron.php

BUT
/usr/bin/lynx -source http://www.yoursite.com/cron.php

If I try the second line in cPanel's cron manager, I get (by email):
Looking up www.yoursite.com
Unable to locate remote host www.yoursite.com.
Alert!: Unable to connect to remote host.
lynx: Can't access startfile http://www.yoursite.com/cron.php

while if I use the first line the job seems to run correctly

I have set up my account yesterday but the domain name is registered and active (I can open it from my browser).

Thank you for your help.

charlesgan
07-29-2007, 06:20 AM
cron will require the file path to work correctly.
domain will not work.

optical
07-29-2007, 10:51 AM
Drupal's cron.php needs to be accessed from the website's domain to work correctly. Now I've found I can use wget for this task.
The strange thing is that, even if I've set-up cPanel's cron manager to run the command every 5 minutes (just to try), the command seems to run at random: one time after 5 minutes, another time after 10 or 15 minuts, then again after 5 minutes from last run; it seems as if it is missing some "stops" along the way.
I have taken a look at the error logs in cpanel and I have seen this in the SUEXEC error_log:
"info: (target/actual) uid: (username/username) gid: (username/username) cmd: cron.php"
sometimes the same line ends with index.php instead of cron.php (this is when I manually refresh index.php).
What does it mean?
BTW what are all those strings in the main error log? just to give you an idea:

[Sun Jul 29 10:41:13 2007] [warn] NameVirtualHost 74.220.202.146:80 has no VirtualHosts [Sun Jul 29 10:41:13 2007] [internal] (19382) /bin/error_logger SIGTERM Received [Sun Jul 29 10:41:13 2007] [warn] NameVirtualHost 74.220.202.146:80 has no VirtualHosts [Sun Jul 29 10:41:13 2007] [warn] NameVirtualHost 74.220.202.146:80 has no VirtualHosts [Sun Jul 29 10:41:14 2007] [internal] (19404) /bin/buffer finished [Sun Jul 29 10:41:14 2007] [internal] (19404) /bin/buffer parent 19391 finished [Sun Jul 29 10:41:17 2007] [internal] (19591) /bin/error_logger started [Sun Jul 29 10:41:16 2007] [notice] FastCGI: wrapper mechanism enabled (wrapper: /usr/local/apache/bin/suexec).

Thank you.

sjlplat
07-30-2007, 01:38 AM
Try using PHP's cURL library to access the the file via HTTP.

http://us2.php.net/curl

Write a simple PHP script to make cURL retrieve the file via HTTP. Use Cron to run the script locally at your required interval.