limiting the amount of data on an output file - date file getting too big (Posted by fairhousing)
hello:
i've got this script that logs every hit to a page on my site on a text file. the script writes all types of environmental variables per hit with the info on one line per hit on the text file. the file is just getting too big too soon. how do i limit the script to writing say only the last 20 hits info to the text file instead the current method i'm using.
thanks in advance
----------
My Site Got Hacked, Check It Out!
http://www.birminghamnet.com
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
Rob Pengelly posted this at 03:04 — 31st October 1999.
They have: 850 posts
Joined: Jul 1999
You could have an extra file that keeps one number, and each time your program is executed, it will open the file, check to see if the number is less 21, and if it is, it will append the logging info to the output file. Than if the number is 21, it will go back to 0, and the new logging info will just ovrwrite all of the old info in the output file. If I get some time today, I will try and write the code, unless someone else can.
----------
[red][Rob P][/red]
[[email protected]]--[[icq]16560402[/icq]]
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
Rob Pengelly posted this at 02:20 — 1st November 1999.
They have: 850 posts
Joined: Jul 1999
OK,
Try incorporating somthing like this into the program:
$numlog = "numberlogging.txt";
$logfile = "logfile.txt";
open(numlog,"<$numlog");
$num=<numlog>;
chop($num);
close(numlog);
if ($num < 21)
{
open(logfile,">>$logfile");
print logfile "$LOG-INFO\n";
close(logfile);
$num++;
}
if ($num == 21)
{
open(logfile,">$logfile");
print logfile "$LOG-INFO\n";
close(logfile);
$num = 0;
}
open(numlog,">$numlog");
print numlog $num;
close(numlog);
Hope this helps.
----------
[red][Rob P][/red]
[[email protected]]--[[icq]16560402[/icq]]
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
fairhousing posted this at 22:14 — 2nd November 1999.
They have: 1,587 posts
Joined: Mar 1999
thanks a bunch robp!
----------
My Site Got Hacked, Check It Out!
http://www.birminghamnet.com
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.