Hi, I've written a little tool, wich looks for the timestamp of files
L???????.log and moves the files into the directories (YYYY-mm-dd).
Mybe it can help you. I think the python code works also under windows.

Usage: ./log_sorter.py /path/to/logs

Code:
#!/usr/bin/python
from glob import glob
from shutil import move
from datetime import datetime
from os import path, mkdir, stat
import sys

def usage():
    print "Please run the Programm with %s /path/to/srcds_logfiles" %
sys.argv[0]
    sys.exit()

if len(sys.argv) <= 1:
    usage()

if path.isdir(sys.argv[1]):
    for log in glob('L???????.log'):
        log_date=datetime.fromtimestamp(stat(log)[8])
        dirname=datetime.strftime(log_date,'%Y-%m-%d')
        if not path.isdir(dirname) and not path.isfile(dirname):
            mkdir(dirname)
        move(log,dirname)
else:
    usage()




I hope there is no error inside. I've tested it with some Logfiles
from my server.


Greetings
DeaD_EyE
sourceserver.info

2011/2/14 Harry Strongburg <harry.h...@harry.lu>:
> On Sun, Feb 13, 2011 at 10:15:09PM +0100, Rikard Bremark wrote:
>> Hi!
>> Anyone here that has any log-scripts for their hlds/srcds setups
>> that moves yesterdays logs to a folder with yesterdays date?
>> Windows/Unix
>
> I personally think grep is nice for sorthing them on-request. If you
> want it to run once a day, crontab would probably work fine.
>
> crontab -e:
> 0 0 * * * cd /path/to/logs/ && mkdir "`date +%F`" && mv *.log "`date +%F`"
>
> Make sure crond is running. That will run daily at midnight system time
> and move all logs that were in that folder on that day into the folder
> it made (i.e. if you ran that command right now, you would probably get
> a folder called "2011-02-14").
>
> I am unsure if srcds properly handles when a log file gets moved or
> renamed, so you might want to be aware of that. Don't have time to check
> right now.
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please 
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
>

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux

Reply via email to