deletefilesolderthan

RPLib – deletefilesolderthan

RPLib.deletefilesolderthan(Number_Of_Days=0, FolderLocation='')[source]

Manages the cleanup of logfiles generated by RPLib.

Parameter Type Description Required
Number_Of_Days Integer Files that are so many days older than the current day will be deleted. Yes
FolderLocation String The folder where the logfiles are being stored. Yes

Returns: Boolean

Usage

  • Used to manage logfiles created over a period of time.
  • Delete log files old than a certain number of days than the current date

Example 1

Simple call with all parameters specified.
Delete files older than 14 days or 2 weeks.
import RPLib

NumberOfDays = 14
LogFileLoc = "C:/GIS/Logs"

RPLib.deletefilesolderthan(NumberOfDays,LogFileLoc)
  • Note All files within this directory will be deleted if they are older than the specified date.

Example 2

Simple call with all parameters specified.
Delete files older than 7 days or 1 weeks.
All files within this directory will be deleted if they are older than the specified date.
Notice that here we are using a UNC path
import RPLib

NumberOfDays = 7
LogFileLoc = "//GIS-SERVER/Scripts/Logs"

RPLib.deletefilesolderthan(NumberOfDays,LogFileLoc)

Example 3

If Else logic with all parameters specified.
Delete files older than 21 days or 3 weeks.
All files within this directory will be deleted if they are older than the specified date.
Notice that here we are using a UNC path
import RPLib

NumberOfDays = 21
LogFileLoc = "//GIS-SERVER/Scripts/Logs"

if RPLib.deletefilesolderthan(NumberOfDays,LogFileLoc):
    print("successful, run another tool")
else:
    print("failed, run another tool")
  • Note - This will start the main ArcGIS Server service through the Windows Services Console.

Table Of Contents

Previous topic

controlservices

Next topic

executesql

This Page