<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Shell script or python to to delete older than 6 months frozen data ? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Shell-script-or-python-to-to-delete-older-than-6-months-frozen/m-p/304651#M57447</link>
    <description>&lt;P&gt;realsplunk,&lt;/P&gt;

&lt;P&gt;For frozen data you can just not use a cold-to-frozen script of directory - by default frozen is deleted and that will resolve your problem going forward.  You can search the &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.0.0/Admin/Indexesconf"&gt;indexes.conf documentation&lt;/A&gt; for "frozen" and get the options that can be set.&lt;/P&gt;

&lt;P&gt;Now that you have Frozen files that are older than what you want to retain, this becomes a simple bash/sh script that just runs a single command on the filesystem.  Google can give you a more thorough answer than we can provide here - the first few returned hits &lt;A href="http://lmgtfy.com/?q=shell+script+delete+files+older+than"&gt;in this search&lt;/A&gt; all do what you need.  Obviously test each and adjust to your needs.&lt;/P&gt;

&lt;P&gt;Happy Splunking!&lt;BR /&gt;
-Rich&lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2017 20:44:44 GMT</pubDate>
    <dc:creator>Richfez</dc:creator>
    <dc:date>2017-11-27T20:44:44Z</dc:date>
    <item>
      <title>Shell script or python to to delete older than 6 months frozen data ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Shell-script-or-python-to-to-delete-older-than-6-months-frozen/m-p/304650#M57446</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;

&lt;P&gt;Would you have an example of shell script or python to to delete older than 6 months frozen data?&lt;/P&gt;

&lt;P&gt;Our frozen data is for example in /var/splunk/frozen (it should delete recursively all files older than 6 months)&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 13:34:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Shell-script-or-python-to-to-delete-older-than-6-months-frozen/m-p/304650#M57446</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2017-11-27T13:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or python to to delete older than 6 months frozen data ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Shell-script-or-python-to-to-delete-older-than-6-months-frozen/m-p/304651#M57447</link>
      <description>&lt;P&gt;realsplunk,&lt;/P&gt;

&lt;P&gt;For frozen data you can just not use a cold-to-frozen script of directory - by default frozen is deleted and that will resolve your problem going forward.  You can search the &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.0.0/Admin/Indexesconf"&gt;indexes.conf documentation&lt;/A&gt; for "frozen" and get the options that can be set.&lt;/P&gt;

&lt;P&gt;Now that you have Frozen files that are older than what you want to retain, this becomes a simple bash/sh script that just runs a single command on the filesystem.  Google can give you a more thorough answer than we can provide here - the first few returned hits &lt;A href="http://lmgtfy.com/?q=shell+script+delete+files+older+than"&gt;in this search&lt;/A&gt; all do what you need.  Obviously test each and adjust to your needs.&lt;/P&gt;

&lt;P&gt;Happy Splunking!&lt;BR /&gt;
-Rich&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 20:44:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Shell-script-or-python-to-to-delete-older-than-6-months-frozen/m-p/304651#M57447</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2017-11-27T20:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script or python to to delete older than 6 months frozen data ?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Shell-script-or-python-to-to-delete-older-than-6-months-frozen/m-p/304652#M57448</link>
      <description>&lt;P&gt;Thanks, I've started this :&lt;/P&gt;

&lt;P&gt;*#!/bin/bash&lt;/P&gt;

&lt;H1&gt;$1 = first arg : main directory&lt;/H1&gt;

&lt;P&gt;curDateEpo=&lt;CODE&gt;date +%s&lt;/CODE&gt;;&lt;BR /&gt;
beforeDateEpo=&lt;CODE&gt;expr $curDateEpo - 15768000&lt;/CODE&gt;&lt;BR /&gt;
echo "Current Epoch time: $curDateEpo";&lt;BR /&gt;
echo "Before 6 months : $beforeDateEpo";&lt;BR /&gt;
for i in $(find $1 -maxdepth 1 -type d)&lt;BR /&gt;
do&lt;/P&gt;

&lt;H1&gt;echo "file $i : ";&lt;/H1&gt;

&lt;H1&gt;printf "\r";&lt;/H1&gt;

&lt;P&gt;read latest earliest &amp;lt;&amp;lt;&amp;lt;${i//[^0-9]/ };&lt;BR /&gt;
earliest=${earliest:0:10}&lt;BR /&gt;
if [ "$earliest" != "" ]&lt;BR /&gt;
then&lt;BR /&gt;
earliestH=&lt;CODE&gt;date -d @$earliest&lt;/CODE&gt;;&lt;BR /&gt;
        # Compare&lt;BR /&gt;
        if [ "$earliest" -lt "$beforeDateEpo" ]&lt;BR /&gt;
        then&lt;BR /&gt;
            echo "$i older";&lt;BR /&gt;
            echo $earliestH;&lt;BR /&gt;
        fi&lt;BR /&gt;
fi&lt;BR /&gt;
done*&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2017 17:55:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Shell-script-or-python-to-to-delete-older-than-6-months-frozen/m-p/304652#M57448</guid>
      <dc:creator>splunkreal</dc:creator>
      <dc:date>2017-11-28T17:55:15Z</dc:date>
    </item>
  </channel>
</rss>

