Welcome to Port3101.org : Your BES Connection Mark forums read | View Forum Leaders
Port3101.org : Your BES Connection



Reply
LinkBack Thread Tools Display Modes
Script to remove BES log files/directories
 
  #1 (permalink)  
Old 02-02-2009, 02:57 PM
BES Activated
 
Join Date: Feb 2009
Posts: 1
Default Script to remove BES log files/directories

'THIS SCRIPT Checks for folders older than 7 days in the path D:\PROGRAM FILES\RESEARCH IN MOTION\BLACKBERRY ENTERPRISE SERVER\LOGS.
'If folders are older than 7 days they are deleted.
'A logfile is written to the D:\PROGRAM FILES\RESEARCH IN MOTION\BLACKBERRY ENTERPRISE SERVER\LOGS path on completion.
'This logfile is overwritten at each run.

On Error Resume Next

'Define the constants
'Number of days to retain the folder
CONST ADJUSTDATE = -7
'Enter your folder path to the BlackBerry logs below
CONST FOLDERPATH = "D:\PROGRAM FILES\RESEARCH IN MOTION\BLACKBERRY ENTERPRISE SERVER\LOGS"
CONST FILENAME = "DeleteLogsScript.log"

'Get the File System Objects
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(FOLDERPATH)
Set subFolders = folder.SubFolders

'Set the log file
sLogFilePath = FOLDERPATH & "\" & FILENAME
set logfile = fso.CreateTextFile(sLogFilePath, True)
'Write the log file
logfile.WriteLine("BES Delete Logs started on " & Now )
logfile.WriteLine("The following folders were deleted")

'Set the date to delete folders older than
dateold = DateAdd("d", ADJUSTDATE, Date)

'Process all the folders
For Each folderObject in SubFolders
errorvalue=0 'ensure the error value is reset for each folder
datemod = DateValue(folderObject.DateLastModified)
'Delete folders that are old

IF datemod < dateold Then
fso.DeleteFolder folderobject, true 'this line deletes the folders
errorvalue = Err.Number

If ErrorValue = 0 Then 'The folder was deleted ok
logfile.WriteLine( folderobject.Name )'record folders that were successfully deleted
Else
If Errorvalue = 70 Then
'Error value 70 denotes the folder could not be deleted for access reasons. Most likely the folder (or a file within it) is in use.
logfile.WriteLine (folderObject.path & " could not be deleted. This folder, or a file within it, may be in use.")
Else
logfile.WriteLine (folderObject.path & " could not be deleted. Unknown error")
End If
End If
End IF
Next

'Write the log file
logfile.WriteLine("BES Delete Logs Completed on.")
logfile.Close

'Clear the variables
Set subFolders = Nothing
Set folder = Nothing
Set fso = Nothing
Set logfile = Nothing
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-02-2009, 03:09 PM
Joolie's Avatar
Super Moderator
 
Join Date: Dec 2008
Location: West Michigan
Posts: 763
Default

Silly question - what is the difference between this script and using the BlackBerry Server Configuration panel (Logging tab) to set the 'Debug log maximum daily file age'?
__________________
You may know me as Juwaack68
Reply With Quote
  #3 (permalink)  
Old 02-04-2009, 09:43 AM
BES Activated
 
Join Date: Feb 2009
Location: FL
Posts: 3
Default

I don't think the "BlackBerry Server Configuration panel (Logging tab) to set the 'Debug log maximum daily file age'" removes the directories it just removes the .txt files, could be wrong though.
Reply With Quote
  #4 (permalink)  
Old 02-04-2009, 01:34 PM
BES Activated
 
Join Date: Feb 2009
Location: NC
Posts: 1
Default

Steve086, you are exactly right. We have 30 days set on our logging and it just removes the txt files within the directories.


-Chris
Reply With Quote
  #5 (permalink)  
Old 04-16-2009, 07:44 PM
BES Activated
 
Join Date: Apr 2009
Location: kansas
Posts: 6
Default

does it delete off of last modified date or the internal stamp date of the log file? Can this be setup in windows schedular
Reply With Quote
  #6 (permalink)  
Old 04-16-2009, 10:20 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default

Quote:
Originally Posted by hayabusa View Post
does it delete off of last modified date or the internal stamp date of the log file? Can this be setup in windows schedular
Great question; I don't know. I created a script to zip log files and ignore having the BES do it ...
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
  #7 (permalink)  
Old 05-11-2009, 01:10 PM
RadHaz75's Avatar
BES Expert
 
Join Date: May 2009
Location: Philadelphia, PA
Posts: 98
Default

so the script deleted the folders for me but the log file didnt update correctly. all it wrote to the log was...

BES Delete Logs started on 5/11/2009 1:08:53 PM
The following folders were deleted
BES Delete Logs Completed on.

also, it left logs more than 7 days old, ran it today and it left logs since 4/25/2009

any ideas?
__________________
Two months ago, I saw a provocative movie on cable TV. It was called The Net, with that girl from the bus.
Reply With Quote
  #8 (permalink)  
Old 05-11-2009, 07:44 PM
Otto's Avatar
Proprietor
 
Join Date: Nov 2008
Location: Atlanta, GA
Posts: 2,033
Blog Entries: 14
Default

By the way, I opened an SDR for having MDS logs (MDAT) to have a configurable retention. A separate one was opened for all other log files, audit logs, orphaned log folders, etc.
__________________
BCSA (4.1, 5.0) | BCSD (4.1, 5.0)

The views expressed by me on Port3101.org are my own and do not necessarily reflect the views of my employer.
Reply With Quote
  #9 (permalink)  
Old 05-12-2009, 12:30 PM
RadHaz75's Avatar
BES Expert
 
Join Date: May 2009
Location: Philadelphia, PA
Posts: 98
Default

fixed a few bugs in your script. it now writes what files it deletes the log and records the date when it finishes.

also if you have the "debug log max daily file age" set, then your folders will have been modified more recently (mine was set to 7 days) and thus not all folders you might expect would be deleted. i changed the one param to folderObject.DateCreated and it then only leaves exactly 7 days (or whatever u specify). it won't delete the webserver logs as they're in use. make sure you move your installer files if you need them as they will be deleted.

'THIS SCRIPT Checks for folders older than 7 days in the path D:\BESLog\BlackBerry Enterprise Server\Logs.
'If folders are older than 7 days they are deleted.
'A logfile is written to the D:\BESLog\BlackBerry Enterprise Server\Logs path on completion.
'This logfile is overwritten at each run.

On Error Resume Next

'Define the constants
'Number of days to retain the folder
CONST ADJUSTDATE = -7
'Enter your folder path to the BlackBerry logs below
CONST FOLDERPATH = "D:\BESLog\BlackBerry Enterprise Server\Logs"
CONST FILENAME = "DeleteLogsScript.log"

'Get the File System Objects
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(FOLDERPATH)
Set subFolders = folder.SubFolders

'Set the log file
sLogFilePath = FOLDERPATH & "\" & FILENAME
set logfile = fso.CreateTextFile(sLogFilePath, True)
'Write the log file
logfile.WriteLine("BES Delete Logs started on " & Now )
logfile.WriteLine("The following folders were deleted")

'Set the date to delete folders older than
dateold = DateAdd("d", ADJUSTDATE, Date)

'Process all the folders
For Each folderObject in SubFolders
ErrorValue = 0 'ensure the error value is reset for each folder
datemod = DateValue(folderObject.DateLastModified)
'Delete folders that are old

IF datemod < dateold Then
folname = folderObject.path
fso.DeleteFolder folderObject, true 'this line deletes the folders
ErrorValue = Err.Number

If ErrorValue = 76 Then
'The folder was deleted ok
logfile.WriteLine (folname & " successfully deleted.") 'record folders that were successfully deleted
Else
If ErrorValue = 70 Then
'Error value 70 denotes the folder could not be deleted for access reasons. Most likely the folder (or a file within it) is in use.
logfile.WriteLine (folderObject.path & " could not be deleted. This folder, or a file within it, may be in use.")
Else
logfile.WriteLine (folderObject.path & " could not be deleted. Unknown error")
End If
End If
End IF
Next

'Write the log file
logfile.WriteLine("BES Delete Logs Completed on " & NOW)
logfile.Close

'Clear the variables
Set subFolders = Nothing
Set folder = Nothing
Set fso = Nothing
Set logfile = Nothing
Set folname = Nothing
__________________
Two months ago, I saw a provocative movie on cable TV. It was called The Net, with that girl from the bus.

Last edited by RadHaz75; 05-12-2009 at 12:34 PM.
Reply With Quote
  #10 (permalink)  
Old 05-15-2009, 06:23 PM
zee zee is offline
BES Activated
 
Join Date: May 2009
Posts: 1
Default

Hi,

What is the file type for this script, is it .vbs?

I changed BES logs directory and I changed it to 15 days, but when I run it, nothing happens.

Thanks in advance.

Quote:
Originally Posted by RadHaz75 View Post
fixed a few bugs in your script. it now writes what files it deletes the log and records the date when it finishes.

also if you have the "debug log max daily file age" set, then your folders will have been modified more recently (mine was set to 7 days) and thus not all folders you might expect would be deleted. i changed the one param to folderObject.DateCreated and it then only leaves exactly 7 days (or whatever u specify). it won't delete the webserver logs as they're in use. make sure you move your installer files if you need them as they will be deleted.

'THIS SCRIPT Checks for folders older than 7 days in the path D:\BESLog\BlackBerry Enterprise Server\Logs.
'If folders are older than 7 days they are deleted.
'A logfile is written to the D:\BESLog\BlackBerry Enterprise Server\Logs path on completion.
'This logfile is overwritten at each run.

On Error Resume Next

'Define the constants
'Number of days to retain the folder
CONST ADJUSTDATE = -7
'Enter your folder path to the BlackBerry logs below
CONST FOLDERPATH = "D:\BESLog\BlackBerry Enterprise Server\Logs"
CONST FILENAME = "DeleteLogsScript.log"

'Get the File System Objects
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(FOLDERPATH)
Set subFolders = folder.SubFolders

'Set the log file
sLogFilePath = FOLDERPATH & "\" & FILENAME
set logfile = fso.CreateTextFile(sLogFilePath, True)
'Write the log file
logfile.WriteLine("BES Delete Logs started on " & Now )
logfile.WriteLine("The following folders were deleted")

'Set the date to delete folders older than
dateold = DateAdd("d", ADJUSTDATE, Date)

'Process all the folders
For Each folderObject in SubFolders
ErrorValue = 0 'ensure the error value is reset for each folder
datemod = DateValue(folderObject.DateLastModified)
'Delete folders that are old

IF datemod < dateold Then
folname = folderObject.path
fso.DeleteFolder folderObject, true 'this line deletes the folders
ErrorValue = Err.Number

If ErrorValue = 76 Then
'The folder was deleted ok
logfile.WriteLine (folname & " successfully deleted.") 'record folders that were successfully deleted
Else
If ErrorValue = 70 Then
'Error value 70 denotes the folder could not be deleted for access reasons. Most likely the folder (or a file within it) is in use.
logfile.WriteLine (folderObject.path & " could not be deleted. This folder, or a file within it, may be in use.")
Else
logfile.WriteLine (folderObject.path & " could not be deleted. Unknown error")
End If
End If
End IF
Next

'Write the log file
logfile.WriteLine("BES Delete Logs Completed on " & NOW)
logfile.Close

'Clear the variables
Set subFolders = Nothing
Set folder = Nothing
Set fso = Nothing
Set logfile = Nothing
Set folname = Nothing
Reply With Quote
  #11 (permalink)  
Old 05-16-2009, 10:25 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default

Quote:
Originally Posted by zee View Post
Hi,

What is the file type for this script, is it .vbs?

I changed BES logs directory and I changed it to 15 days, but when I run it, nothing happens.

Thanks in advance.
That is indeed VBS ... just use the script I made
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
  #12 (permalink)  
Old 07-20-2009, 07:29 PM
BES Activated
 
Join Date: Feb 2009
Location: Costa Rica
Posts: 1
Default

Hi guys, I just want to know what happend with the Webserver and Installer Folders/logs could those be deleted?
Reply With Quote
  #13 (permalink)  
Old 07-20-2009, 08:03 PM
hdawg's Avatar
Proprietor
 
Join Date: Nov 2008
Posts: 2,257
Blog Entries: 147
Default

Sure you can delete them. Once the installation is successful you're all set. If the webserver directory is empty you can delete it too.
__________________
http://blog.port3101.org/hdawg/
Reply With Quote
Reply

Bookmarks

Tags
bes, file, folders delete, log

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I remove BES from an ebay BB 9000 ? nlj Power Users 11 08-29-2010 01:27 PM
Best practise. Remove BIS emails from handheld millardus Port 3101: The BES Admin Bar & Grill 1 11-23-2009 01:45 PM
Script to Zip Log Files Sith_Apprentice Scripts & Tools / Hints & Tricks 3 07-15-2009 04:06 PM
KB10877 - How to remove a BlackBerry smartphone user from a BES hdawg Featured BlackBerry KB Articles 0 06-16-2009 11:22 AM
How To: Remove IT Policy John Clark Power Users 0 01-02-2009 03:24 PM


All times are GMT -4. The time now is 05:00 AM.
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.


 

SEO by vBSEO 3.3.2 PL2