<div dir="ltr">Also a caution on this... you may want to retain the file's modified time in something like purge.modified... so you can also re-calc for files where purge.modified != file modified time.  Else you may purge something too early.<div><br></div><div>Alec</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 29, 2021 at 6:53 PM Alec <<a href="mailto:anacreo@gmail.com">anacreo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Based on the problem you have.<br><div><br></div><div>I would write an mmfind / mmxarg command that sets a custom attr such as puge.after, have a ksh/perl/php script that simply makes the necessary calculations using all the tricks it has...  Skip files that already have the attribute set, or are too new to bother having the attribute.</div><div><br></div><div>Then use a single purge policy to query all files that have a purge.after set to the appropriate datestamp.</div><div><br></div><div>You could get way more concise with this mechanism and have a much simpler process.</div><div><br></div><div>Alec</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 29, 2021 at 4:32 PM Owen Morgan <<a href="mailto:owen.morgan@motionpicturesolutions.com" target="_blank">owen.morgan@motionpicturesolutions.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div style="color:rgb(33,33,33);background-color:rgb(255,255,255);text-align:left" dir="auto">
<span style="font-size:17px">Hi all,</span><br>
<br>
<span style="font-size:17px">Sorry I appear to have missed a load of replies and screwed up the threading thing when looking online...  not used to this email group thing! Might look at the slack option!</span><br>
<br>
<span style="font-size:17px">Just wanted to clarify my general issue a bit:</span><br>
<br>
<span style="font-size:17px">So the methodology I've started to implement is per department policy files where all rules related to managing a specific teams assets are all in one policy file and then I have fine control over when and how each departments rule
 run, when, and potentially (if it mattered) what order etc.</span><br>
<br>
<br>
<span style="font-size:17px">So team a want me to manage two folders where in folder 1a all files older than 4 week days of age are deleted, and in filder 1b all files older than 8 week days are deleted.</span><br>
<br>
<span style="font-size:17px">They now want me to manage a different set of two folders with two different "thresholds" for how old they need to be in week days before they delete (ie. I now need additional rules for folders 2a and 2b).</span><br>
<br>
<br>
<span style="font-size:17px">The issue is for each scenario there is a different 'offset' required depending on the day of the week the policy is run to maintian the number of weekdays required (the 'threshold' is always in weekdays, so intervening weekends
 need to be added to take them into account).</span><br>
<br>
<span style="font-size:17px">For instance when run on a Monday, if the threshold were 4 weekdays of age, I need to be deleting files that were created on the previous Tuesday. Which is 6 days (ie 4 days + 2 weekend days). If the threshold was 8 week days the
 threhold in terms of the policy would be 12 (ie 8 plus 2x 2 weekend days).</span><br>
<br>
<br>
<span style="font-size:17px">The only way I was able to work this out in the sql like policy file was to split the week days into groups where the offset would be the same (so for 4 week days, Monday through Thursday share the offset of 2 - which then has to
 be added to the 4 for the desired result) and then a separate rule for the Friday.</span><br>
<br>
<br>
<span style="font-size:17px">However for every addition of a different threshold I have to write all new groups to match the days etc.. so the policy ends up with 6 rules but 150 lines of definition macros....</span><br>
<br>
<br>
<span style="font-size:17px">I was trying to work out if there was a more concise way of, within the sql like framework, programmatically calculating the day offest the needs to be added to the threshold to allow a more generic function that could just automatically
 work it out....</span><br>
<br>
<br>
<span style="font-size:17px">The algorithm I have recently thought up is to effectively calculate the difference in weeks between the current run time and the desired deletion day and multiply it by 2.</span><br>
<br>
<br>
<span style="font-size:17px">Psudocode it would be (threshold is the number of week days for the rule, offset is the number that needs to be added to account for the weekends between those dates):</span><br>
<br>
<br>
<span style="font-size:17px">If current day of month - threshold = sunday, then add 1 to the threshold value (sundays are de oted as the week start so Saturday would represent the previous week).</span><br>
<br>
<span style="font-size:17px">Offset = (difference between current week and week of (current day of month - threshold)) x 2</span><br>
<br>
<span style="font-size:17px">A worked example:</span><br>
<br>
<span style="font-size:17px">Threshold = 11 week days</span><br>
<span style="font-size:17px">Policy run on the 21st Jan which is the week 4 of 2021</span><br>
<br>
<span style="font-size:17px">21st - 11 days = Sunday 10th</span><br>
<br>
<span style="font-size:17px">Therefore need to add 1 to threshold to push the day into the previous week. New threshold is 12</span><br>
<br>
<span style="font-size:17px">Saturday 9th is in week 2 of 2021 so the offset is week 4 - week 2 = 2 (ie difference in weeks) x 2 which is 4.</span><br>
<br>
<span style="font-size:17px">Add 4 to the original 11 to make 15.</span><br>
<br>
<span style="font-size:17px">So for the policy running on the 21st Jan to delete only files older than 11 week days of age I need to set my rule to be
</span><br>
<br>
<span style="font-size:17px">Delete where ((Current_date - creation_time) >= interval '15' days</span><br>
<br>
<br>
<span style="font-size:17px">Unfortunately, I'm now struggling to implement that algorithm..... it seems the SQL-ness is very limited and I cant declare variables to use or stuff.... its a shame as that algorithm is generic so only needs to be written once
 and you could have ad many unique rules as you want all with different thresholds etc...</span><br>
<br>
<span style="font-size:17px">Is there another way to get the same results?</span><br>
<br>
<span style="font-size:17px">I would prefer to stay in the bounds of the SQL policy rule setup as that is the framework I have created and started to implement..</span><br>
<br>
<span style="font-size:17px">Hope the above gives more clarity to what Im asking.... sorry if one of the previous rplies addresses this, if it does I clearly was confused by the response (I seriously feel like an amateur at this at the moment and am having
 to learn all these finer things as I go).</span><br>
<br>
<span style="font-size:17px">Thanks in advance,</span><br>
<br>
<span style="font-size:17px">Owen.</span><br>
</div>
<div><table cellpadding="0" cellspacing="0" border="0" style="width:100%"><tbody><tr style="font-size:0px"><td align="left" style="vertical-align:top"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0px;line-height:normal"><tbody><tr style="font-size:0px"><td style="padding:0px"> </td><td style="padding:10px 0px 0px"> </td></tr><tr style="font-size:0px"><td align="left" style="padding:0px 4px 0px 0px;border-top:none;border-right:1px solid rgb(255,204,0);border-bottom:none;border-left:none;vertical-align:middle"><img src="http://www.motionpicturesolutions.com/wp-content/uploads/2018/06/MPSEmail.jpg" height="91" border="0" alt="" style="height: 91px; min-height: 91px; max-height: 91px; font-size: 0px;"></td><td align="left" style="padding:10px 0px 10px 10px;vertical-align:middle"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;font-size:0px;font-style:normal;font-weight:700;white-space:nowrap"><tbody><tr style="font-size:12px;color:rgb(255,204,0)"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif">Owen Morgan<span style="font-family:remialcxesans;font-size:1px;color:rgb(255,255,255);line-height:1px">​</span></td></tr><tr style="font-size:10.67px;color:rgb(35,35,35)"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif">Data Wrangler</td></tr><tr style="font-size:10.67px;color:rgb(35,35,35)"><td align="left" style="vertical-align:top;font-family:Calibri,Arial,sans-serif">Motion Picture Solutions Ltd</td></tr><tr style="font-size:0px"><td align="left" style="vertical-align:top"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0px"><tbody><tr style="font-size:0px"><td align="left" style="padding:10px 0px 0px;vertical-align:top"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0px;color:rgb(35,35,35);font-style:normal;font-weight:400;white-space:nowrap"><tbody><tr style="font-size:10.67px"><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif"><span style="font-weight:700">T:</span> <a id="gmail-m_5353806869892021276gmail-m_5240340954273844209gmail-m_1546056034727318793LPlnk689713" style="text-decoration:none;color:rgb(35,35,35)"><strong style="font-weight:400"></strong></a></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr style="font-size:0px"><td align="left" style="vertical-align:top"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0px;color:rgb(35,35,35);font-style:normal;font-weight:400;white-space:nowrap"><tbody><tr style="font-size:10.67px"><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif"><span style="font-weight:700">E:</span> <a href="mailto:owen.morgan@motionpicturesolutions.com" id="gmail-m_5353806869892021276gmail-m_5240340954273844209gmail-m_1546056034727318793LPlnk689713" style="text-decoration:none;color:rgb(35,35,35)" target="_blank"><strong style="font-weight:400">owen.morgan@motionpicturesolutions.com</strong></a></td><td align="center" style="vertical-align:middle;font-size:12px;color:rgb(254,212,0);font-family:Calibri,Arial,sans-serif"> | </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;font-weight:700">W: <span style="font-weight:400"><a href="https://www.motionpicturesolutions.com/" id="gmail-m_5353806869892021276gmail-m_5240340954273844209gmail-m_1546056034727318793LPlnk689713" style="text-decoration:none;color:rgb(35,35,35)" target="_blank"><strong style="font-weight:400">motionpicturesolutions.com</strong></a></span></td></tr></tbody></table></td></tr><tr style="font-size:0px"><td align="left" style="vertical-align:top"><table cellpadding="0" cellspacing="0" border="0" style="font-size:0px;color:rgb(35,35,35);font-style:normal;font-weight:400;white-space:nowrap"><tbody><tr style="font-size:10.67px"><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif;font-weight:700">A: </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif">Mission Hall, 9‑11 North End Road</td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif">, </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif">London</td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif">, </td><td align="left" style="vertical-align:middle;font-family:Calibri,Arial,sans-serif">W14 8ST<br></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr style="font-size:0px"><td align="left" style="vertical-align:top"><table cellpadding="0" cellspacing="0" border="0" style="width:100%;font-size:0px"><tbody><tr style="font-size:0px"><td align="left" style="padding:10px 0px 0px;vertical-align:top"><table cellpadding="0" cellspacing="0" border="0" style="white-space:normal;color:rgb(192,192,192);font-size:14.67px;font-family:Calibri,Arial,sans-serif;font-weight:400;font-style:normal;text-align:justify;width:100%"><tbody><tr style="font-size:10.67px"><td style="font-family:Calibri,Arial,sans-serif">Motion Picture Solutions Ltd is a company registered in England and Wales under number 5388229, VAT number 201330482</td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></div></div>

_______________________________________________<br>
gpfsug-discuss mailing list<br>
gpfsug-discuss at <a href="http://spectrumscale.org" rel="noreferrer" target="_blank">spectrumscale.org</a><br>
<a href="http://gpfsug.org/mailman/listinfo/gpfsug-discuss" rel="noreferrer" target="_blank">http://gpfsug.org/mailman/listinfo/gpfsug-discuss</a><br>
</blockquote></div>
</blockquote></div>