Rating:
by DeaD_EyE, Monday, February 14th 2011, 11:11pm
Quoted
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
------
//Rikard 'Zapy' Bremark
![]() |
Source code |
1 2 |
crontab -e: 0 0 * * * cd /path/to/logs/ && mkdir "`date +%F`" && mv *.log "`date +%F`" |
![]() |
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#!/usr/bin/python
from glob import iglob
from shutil import move
from datetime import datetime
from os import chdir, 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()
now = datetime.today().strftime('%Y-%m-%d')
if path.isdir(sys.argv[1]):
chdir(sys.argv[1])
for log in iglob('L???????.log'):
log_date=datetime.fromtimestamp(stat(log)[8])
dirname=datetime.strftime(log_date,'%Y-%m-%d')
if dirname == now:
continue
if not path.isdir(dirname) and not path.isfile(dirname):
mkdir(dirname)
if not path.isfile(path.join(dirname,log)):
move(log,dirname)
else:
usage()
|
![]() |
Source code |
1 |
log_sort.py /pfad/zu/den/logs |
![]() |
Source code |
1 2 |
7a3364ac975ca9cb66c1ee11b4521d76 log_sorter.exe c94ee175212d0f745a91f8c0a9f0be67 log_sorter.zip |
![]() |
Source code |
1 |
log_sorter.exe C:\HLServer\orangebox\cstrike\logs |
This article has been read 67,578 times.
Tags: Datum, Logs, Python, sortieren, SRCDS
Friday, June 17th 2011, 11:43pm
Sunday, June 5th 2011, 8:42pm
Sunday, May 29th 2011, 5:37pm
Thursday, April 21st 2011, 8:13am
Tuesday, March 22nd 2011, 1:54pm
by paini (Jan 27th 2022, 10:48am)
by theJEWandI (Sep 20th 2011, 5:13am)
by zhuowu (Sep 20th 2011, 2:44am)
by pisey2002my (Sep 16th 2011, 4:09am)
by MAMYCAY (Sep 16th 2011, 3:08am)
by HSFighter Feb 8th 2011, 7:32pm