Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Creating a cronjob to refresh news site
Old 10-12-2007, 07:29 PM Creating a cronjob to refresh news site
Junior Talker

Posts: 1
Trades: 0
Hello,

I've built a news site using SimplePie to pull in a set of feeds and display them on a page. The caching is working but the problem is that the first initial load is slow. After that, you can hit refresh and it loads very quickly. I'd like to eliminate that first slow load by creating a cronjob, which is what I've heard many other people do. I'm very new to crons and programming in general so hopefully someone can help me understand this.

I found one example of a guy using the following cron to automatically visit his page and he syncronized the cache duration, thus eliminating any slow starts:

Code:
0,15,30,45 * * * * wget -q --spider http://thewebsite.com
The problem I found was that my host doesn't support wget (or lynx, or ssh) so I've been trying to write a cron that will achieve the same results but using either curl or php. Here is what I have so far:

Code:
*/15 * * * * curl --silent --compressed http://www.mysite.com/index.php
Code:
*/15 * * * * php /home/username/public_html/index.php
Again, I found these examples from reading other resources so I'm not entirely sure what they're doing or if they're correct for my situation. I've also set the cache duration to match at 15 minutes. When I run either the curl or php cron above, in my e-mail I receive the entire html source for the specified index.php. I'm assuming this means they're working correctly, but still my news page has that initial slow load. I'm open to any thoughts or ideas. Thanks in advance.
eightgames is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-14-2007, 05:29 AM Re: Creating a cronjob to refresh news site
pirates's Avatar
Super Talker

Posts: 133
Trades: 1
Well if you are useing cpanel for yourcron job you can do the simple version like this

CRON Command is in the Following Format
[ Minute - Hour - Day - Month - Weekday ] - Command
COMMAND, can be broken down in
[PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]
COMPLETE CRON command
[ Minute - Hour - Day - Month - Weekday ] [PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]
timing is spedified using * symbols
* * * * * => Execute every minute
0 * * * * => Execute every Hour
0 0 * * * => Execute every mid-night
0 0 0 * * => Execute every Month
0 0 0 0 * => Execute every Weekday

UNIX command, You will have to Mention the PATH of PHP file
PATH TO PHP : /usr/local/bin/php

Possible Command line Arguments you can use


-a Run interactively
-b <addressort>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.


Complete CRON command would be
0 * * * * /usr/local/bin/php -q /home/tom/public_html/cron/myfile.php


Not sure this will help you for curl as i not no much on curl
here a link

http://www.weberdev.com/get_example-3441.html

http://docs.phplist.com/CronJobExamples
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
pirates is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Creating a cronjob to refresh news site
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.68650 seconds with 12 queries