Jump to content

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.

CRON job on UNIX or Scheduled task on Windows. Create a script that runs once a week and have it wipe the hit counter clean.

 

If you want more help post some code....something cause right now your question is way too vague.

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/

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.