Click here to Login





                                                   How to remove trace/log-files by script

  1

0
SystemTrade
2013-08-23 11:22:00


On every start of QS a log-file is generated, which is very helpful if you want to analyse potential problems.
As these log-files are not deleted automatically, the little script below - if you want to have a clean system - can do this deletion after a certain number of days that can be set through the variable "MinFileAgeInDays".
If you prefer, you can also add this script to your bookmark panel or you add it to the task manager to have it run, e.g. on every application start.
In case of any question, just let me know. Enjoy!

//--------- C# Remove old trace files -------------
int MinFileAgeInDays = 30;
string FilePattern = "Trace*.log";

string[] TraceFiles = System.IO.Directory.GetFiles(
App.Main.GetUserDatabasePath().Substring(0, App.Main.GetUserDatabasePath().LastIndexOf("Database")) + "Trace",
FilePattern, System.IO.SearchOption.TopDirectoryOnly);
int NbDeletedFiles = 0;
foreach (string TraceFile in TraceFiles)
{
if ((System.DateTime.Now - System.IO.File.GetLastWriteTime(TraceFile)).TotalDays >= MinFileAgeInDays)
{
System.IO.File.Delete(TraceFile);
NbDeletedFiles++;
}
}
Global.Trace1("*** " + NbDeletedFiles.ToString() + " trace files deleted. ***");



Juliettpapa
2013-08-23 11:47:12

  0

(I will answer in English, even though I'm German too):

Great idea, but for me, it doesnt work.
Look: http://screencast.com/t/r6OIAPif2

Regards
juliettpapa



SystemTrade
2013-08-23 12:54:16

  0

Hmm, please add the following line to the script
Global.Trace1(App.Main.GetUserDatabasePath());
and check the output window and let me know the reported database path.
As the trace directory is derived from the UserDatabasePath, it might be that you have a different file structure.



Juliettpapa
2013-08-23 13:13:17

  0

My Database is on X:\....\Database\XXXXXX because i use QS on different computers in a network.

But my trace directory is on C:\Program Files\CTrading\QuantShare\Trace on every PC.

When discussing with QS support about making QS capable using network drives they said to me, that some data is still stored in a local drive even though the database is on X: (i. e. work spaces or short cuts).

So every time when changing a shortcut on one computer i have to change it on the others...

Therefore i have three trace folders on three computers. But all with the same path.

C:\Program Files\CTrading\QuantShare\Trace


How can i change your script with a hardcoded path?



SystemTrade
2013-08-23 13:31:49

  0

Try this one please:

//--------- C# Remove old trace files -------------
int MinFileAgeInDays = 30;
string FilePattern = "Trace*.log";
string TracePath = "C:\\Program Files\\CTrading\\QuantShare\\Trace";

string[] TraceFiles = System.IO.Directory.GetFiles(TracePath, FilePattern, System.IO.SearchOption.TopDirectoryOnly);
int NbDeletedFiles = 0;
foreach (string TraceFile in TraceFiles)
{
if ((System.DateTime.Now - System.IO.File.GetLastWriteTime(TraceFile)).TotalDays >= MinFileAgeInDays)
{
System.IO.File.Delete(TraceFile);
NbDeletedFiles++;
}
}
Global.Trace1("*** " + NbDeletedFiles.ToString() + " trace files deleted. ***");



Juliettpapa
2013-08-23 13:40:52

  0

It works now. I have added it to the task manager.
Well done!

jp



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
How far are the close prices from the support line
Identify Spilts Screener Script
Bursa Malaysia EOD data
US Stock symbols - CUSIP
Structural Arbitrage Strategy

How-to Lessons
How to remove non-active securities
How to run a screen or a watchlist from a script
How to get stocks for a particular index using the global script
How to execute a script at regular intervals
How to remove a chart pane's margins

Related Forum Threads
Script to remove Symbols from an Index
how to remove non trading day entries
How to remove symbols that have zero volume
Global Script For How To Export In MetaStock Format In Ascii Layo...
wget/curl symbol lists in script editr

Blog Posts
How scripts communicate with each other
How to Download Trading Data for Certain Securities Only
How to get buy and sell orders for a portfolio based on a trading...
How to build and backtest a robust stock trading system
How to use QuantShare screener to trade penny stocks









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.