SAS Life Science Analytics Framework and the clinical data products from SAS

How to automate cleanup of trash can?

Reply
SAS Employee
Posts: 4

How to automate cleanup of trash can?

    Most users would like an object to remain in a trashcan a certain number of days to ensure the 'delete' of the file was not a mistake.  So how can a file remain in the trashcan for 'N' number of days and then be deleted?  A scheduled job can be setup to automate the cleanup of a trashcan.  However, in order for this to work, a modification needs to be made to the object in the trashcan in order to make sure that object has reached it maturity (I.E. spent enough time in the trashcan before being permanently deleted). The reason for this modification is, when an object is deleted in SDD, the modification date of the object in the trashcan doesn’t change.   See Illustration below:  The SDD_hierarchy_model2.xls file was created (and not modified) on 11/18/2011.

pic1-2.png

  When the object SDD_hierarchy_model2.xls is deleted, the Created and Modified date remains the same in the trashcan.

pic1-2.png


      Therefore, if you designate a cleanup cycle for a given trashcan to be seven days (an object can stay in the trashcan seven days before permanent deletion) and the modification date is not altered, an object that was created eight days ago and then deleted will only be in the trashcan 1 day.  It will be deleted on the first cleanup cycle since the difference from the modification date and the current date is greater than the cleanup cycle.

  In order to prevent this from happening, the object needs to be modified in some way.  This will alter the modification date of the file to when the object was deleted.
This can be programmatically accomplished by altering a rarely used metadata field for the object (keywords).  The scheduled program would first check the object for a date in the keyword field, if it doesn’t find one, it adds the current date (day 1 in trashcan).  

When the schedule runs, the SDD_hierarchy_model2.xls file Modified date is altered:

pic1-2.png


   Looking at the actual properties of the SDD_hierarchy_model2.xls file, the modification by the scheduled program show the Keywords: metadata filed has ben updated.

pic1-2.png


      Upon subsequent checks (as days go by) this date information is checked against the current date.  Once maturity has been reached (difference of day(s) equals the maximum time kept in the trashcan) the item can be programmatically deleted using the SDD API deletefile  macro.   By using this coding practice, the problem of exceeding a trashcan’s capacity will not be encountered.

Ask a Question
Discussion stats
  • 0 replies
  • 234 views
  • 0 likes
  • 1 in conversation