Jump to content

[SOLVED] Hit counter that resets weekly?


nfx

Recommended Posts

Each of my pages counts a hit when the page is loaded. So I have a counter that totals everything. What I'd like is to make it count a hit twice when a page is loaded, one for the original counter and one that resets back to zero every 7 days. The only part I don't know how to do is to get it to reset.

 

I mean right now the total hit counter isn't very useful. Pages that have been on there for a couple years are going to be leaps and bounds higher than recently added pages. I just want a more relative counter.

So I just create a php file with nothing but the code to connect to the database and to set each counter to 0? And the cron command is the url to the php file? Sorry, I know I already checked this off as solved, just want to make sure before I ruin something.

Yes I'm using cPanel.

 

If I wanted it to run every Sunday at 2am, would my crontab be?

 

* 02 * * sun /somefolder/script.php

 

Or is it not that simple?

 

You would need to use the PHP CLI command for UNIX to accomplish that. Google PHP CLI CRON for examples.

 

EDIT:

For your script it would look like

* 2 * * 0 /usr/bin/php -f /home/phpscripts/yourscript.php

 

Given that php is installed to /usr/bin/

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.