|
|
|||||||
basically I want to delet old event log in all my servers centraly by running a script, I have written a script for that but it seems it is not enumerating files in remote servers. code:any better idea to do this ??$dt1=@date |
||||||||
|
|
|||||||
You don't provide enough information. Depending on what sort of eventlog you are dealing with can make a difference. Most eventlogs take care of themselves and should never be deleted. Also, most eventlogs are in constant use and so GetFileTime() will not work. Here is a script to demonstrate that. code:Break on |
||||||||
|
|
|||||||
i want to delete event log files which is older than 7 days, I shared event log directory as \\server\eventlog now I am trying to get the file date of each file inside the directory and if it is more than 7 days old of current date delete it. I hope I made it clear now. |
||||||||
|
|
|||||||
Well, you still don't say what sort of logs these are so I can't say if there is an in-use issue. I did notice though that you are trying to compare a string with a value. If ($result1 < $sub1) |
||||||||
|
|
|||||||
Regardless of the type event log I looking for the date of the file not time. That's why i used getfiletime() like code:This way I am getting only date of the file, I use valu to minus 7 from current date. I know I am doing some thing crap here, Pls tell me to do better. |
||||||||
|
|
|||||||
Val() |
||||||||
|
|
|||||||
yep, les is right. change: code:to:If ($result1 < $sub1) code:uhm, while tried to post these lines without code-tags, board was yelling about html-tags!If ($sub1 > $result1) wtf |
||||||||
|
|
|||||||
Thanx Lonkero I'll change it, But that is not the main issue, How can I Enumerate remote Pc's files using DIR() function ?? If I can achive this task the rest I can do within no time. Dir() is working fine in local but if I do it like DIR("\\server\shareddrive") it dosent work I tried by mapping the drive too like DIR ("f:\") no use |
||||||||
|
|
|||||||
just issue dir() and return the error code. I bet it's 5. checked to see is there problem with simple scriptlet: code:and it worked just fine.dir("e:\") ;connected to jooel3.lonkero...fi |
||||||||
|
|
|||||||
Guys I found out the issue. My script was failing not in enumeration part but in getfiletime function, This event log file name is having "@" charecter when i removed this charecter it was giving file date and time. quote:here $ss1 is giving the output $ss no. there are thousends of files in the directory I cannot rename all manuelly |
||||||||
|
|
|||||||
nope. here the issue is that you write it manually. if you want to write it, you need to read your manual: $ss=GetFileTime ("f:\MOSAIC01MZsec14-9-2003@@8-20-5.evt") now, did you or did you not check the error? |
||||||||
|
|
|||||||
Lonkero I know about "@"in kix Itried with double ("@@") too but it is not giving any result, Pls rename any of your file with "@@" and try. I am sure it will fail to produce any result. |
||||||||
|
|
|||||||
I did. there are some cracks and other not so good stuff so can't show the results. the file was readen fine. code:file tested with:dir("e:\") web@monitor.kix - 2003/09/25 02:50:16 I still ask you, did you or did you not check the error code??? [ 28. September 2003, 10:33: Message edited by: Lonkero ] |
||||||||
|
|
|||||||
quote:Well it is not giving any error code... Now i am running only a one line code code:$ss is returning blank line as soon as I remove "@" from file name it is returning file date and time. |
||||||||
|
|
|||||||
quote:Well it is not giving any error code... Now i am running only a one line code code:$ss is returning blank line as soon as I remove "@" from file name it is returning file date and time. |
||||||||
|
|
|||||||
lol. make your file that SINGLE @. and then use this: like you said, you SHOULD know, you CANT!!! use the single @-sign in the string. how hard is that. |
||||||||
|
|
|||||||
saleem, btw. not getting mad at you. just at me, as can't explain well enough. |
||||||||
|
|
|||||||
Sorry Lonkero I knoe I am giving you hard time Finelly it gave me some result. code:and the reuslts are quote:what do you think I need to rename the file name with Chr(64) ? it's weired right ? |
||||||||
|
|
|||||||
no. you still didn't double the @. chr(64) gives same results as with double @@. I gave you that line to test do you do what I ask you to. no, you don't. there is no problem whatsoever if you would do as you are informed to do. |
||||||||
|
|
|||||||
if you try with this line, it will work too: $ss=GetFileTime ("f:\MOSAIC01MZ"+"@"+"ab.evt") which again is same as: $ss=GetFileTime ("f:\MOSAIC01MZ@@ab.evt") |
||||||||
|
|
|||||||
Thnax Lonkero...... It worked..... I was doing a mistake that I was changing the file name too with two @@ (dump ass ) now it worked. now if we go back back to old cord code:I think I have to add that extra "@" to code:here somewhere right ?$dt=GetFileTime ("f:\$dr") |
||||||||
|
|
|||||||
nope. the double stuff for @ and $ and % only is effective when you do type it yourself in the scriptfile. thus, if you read the filename, it will be in the variable and the double thing does not infect it. but use these lines, as they "follow" best practise: code:$dt=GetFileTime ("f:\"+$dr) |
||||||||
|
|
|||||||
Saleem, Like I said in my first post! quote:In your code, you do: $dt=GetFileTime ("\\server\eventlog\$dr") ? $dt If you would have said that $dt returns nothing in your first instead of tenth post, we could have solved this with less than 22 posts! If you cannot learn to provide more details, I will not look at any more of your posts. |
||||||||
|
|
|||||||
A current eventlog can never be older than seven days as it is constantly in use. However, backed-up eventlog can be older than seven days. Now, if you want to delete those eventlogs, then why do you back them up in the first place? Alos, you cna specify how eventlogs overwriten the evententries, and you can also resize the eventlogsizes to have all events for a specific time period into them. Thus, as other already repeatedly told you, please explain to us in detail what exactly you try to accomplish. |
||||||||
|
|
|||||||
LLigetfa It was not puposefully even I came to know the problem is in GetFiletime() only only when I reach 10th post. As i mentioned in my subject line I thought the problem is with Enumerating remote files. Any way thanx for your support. sealeopard We have some unimportent servers which we are not spending money for backup , hence we decided to keep log files for last seven days by deleting them on weekly basis. Geographically this servers are located in diffrent regions so I thought of writing a script to connect this servers and deleting event files centrelly. Lonkero I'll test the code and post the result. |
||||||||
|
|
|||||||
So, you're saying that the eventlogs on those "unimportant" servers are getting so big within a seven-day period, that thet needs to manually be deleted? Just set "Overwrite events older than 7 days" and set the eventlog file size to e.g. 8192kB and they will purge themselves automatically. |
||||||||
|
|
|||||||
This are our test servers, now a days we are doing some extensive application tests on this servers so some how event logs are getting heavy ver fast. Thanx for the suggestion, good news that script is also working now. |