    {"id":37,"date":"2012-03-28T11:07:47","date_gmt":"2012-03-28T09:07:47","guid":{"rendered":"http:\/\/www2.emiwa.pl\/?p=37"},"modified":"2025-06-04T09:44:55","modified_gmt":"2025-06-04T07:44:55","slug":"linux-skypty-usuwanie-katalogow-starszych-niz","status":"publish","type":"post","link":"https:\/\/www.emiwa.pl\/?p=37","title":{"rendered":"Linux skypty &#8211; Usuwanie katalog\u00f3w starszych ni\u017c &#8230;"},"content":{"rendered":"<p><!--more-->Prosty skrypt, kt\u00f3ry w przekazanej do skryptu \u015bcie\u017cce wyszukuje i usuwa katalogi starsze ni\u017c to podano w sta\u0142ej ILE.<\/p>\n<blockquote>\n<pre>#!\/bin\/bash\r\nILE=3\u00a0              #dni\r\nGDZIE=$1            #katalog do przeszukania zak\u0142adamy ze s\u0105 tu tylko katalogi\r\nDATA=`date +%-j`\u00a0\u00a0\u00a0 #czyli dzi\u015b mamy $DATA dzie\u0144 roku\r\nfor i in $GDZIE\/* ; do\r\n  DATA_PLIKU=`ls -Gd --full-time $i`;   # --full-time zwraca dat\u0119 idealna do przekazania do programu data\r\n  PLUS=`expr index \"$DATA_PLIKU\" \"\\+\"`; # - to co zwr\u00f3ci\u0142 ls trzeba obci\u0105\u0107 do samej daty wi\u0119c ustalamy od kt\u00f3rego znaku tniemy\r\n  PLUS=$[ $PLUS - 31 ]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \r\n  DATA_PLIKU=`date +%-j -d \"${DATA_PLIKU:$PLUS:35}\"` # i ju\u017c wiemy kt\u00f3rego dnia roku za\u0142o\u017cono katalog\r\n  if (( $DATA \\&gt;= $DATA_PLIKU )); then\u00a0              # problem zawsze stanowi zmiana roku wi\u0119c staramy si\u0119 to wykry\u0107\r\n    if (( (($DATA - $DATA_PLIKU)) \\&gt; $ILE )); then\r\n       rm -R $i\r\n    fi\r\n  else\r\n    if (( ((365 + $DATA - $DATA_PLIKU)) \\&gt; $ILE )); then\r\n       rm -R $i\r\n    fi\r\n  fi\r\ndone<\/pre>\n<p>&nbsp;<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[21,19,32],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-newbie","tag-bash","tag-linux","tag-skrypt"],"_links":{"self":[{"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37"}],"version-history":[{"count":2,"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.emiwa.pl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}