Hi guys! I've recently made a python script, to remove old sourcetv/hltv records, because who needs records older than 5 days? It's script to those people who have their own dedicated server/VPS in every other case i'm sure that your hosting provider is doing it for you (;
It's reading date in format from csgo_demo_crash_fix plugin, in every other case it might not work so u're using it on your own risk (;
Code:
import os
import datetime
demos_directory = "/home/codmod/game/server/csgo/demos/"
now = datetime.datetime.now()
for file in os.listdir(demos_directory):
if file.find(".dem") == -1 or file.find("auto") == -1:
continue
splitted = file.split("-")
date = splitted[1]
year = date[:4]
month = date[4:6]
day = date[6:8]
datetime_instance = datetime.datetime(int(year), int(month), int(day), 0, 0)
diff = now - datetime_instance
if(diff.days > 5):
os.remove(demos_directory + file)
All you have to do is:
1. Make python file and upload it on your dedicated server, name it like you like, for example: delete_demos.py and put in /home/csgo/
2. Change path in variable demos_directory to yours, where your demos are stored,
3. chmod +x /home/csgo/delete_demos.py
4. crontab -e
5. write record in crontab like: */5 * * * * python /home/csgo/delete_demos.py
6. voila, your demos are gonna be deleted in every 5 minutes, when they are older than 5 days.