<?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: Auto Cleanup script for log files in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/752241#M22550</link>
    <description>&lt;P&gt;As soon as you start doing administrator work, Maxim 15 (Know Your Playing Field) turns from a strong recommendation into a requirement.&lt;/P&gt;
&lt;P&gt;Knowing at least the basics of bash scripting (creation and use of environment variables, conditional execution, regular expressions, writing to and reading from files, piping, just to name a few) is a must.&lt;/P&gt;
&lt;P&gt;You also need to get a grasp on the important UNIX utilities like find, grep, ls, ps. Maxim 6 (Google Is Your Friend) is a big helper in this respect.&lt;/P&gt;
&lt;P&gt;Since I do not have to do shell scripting often, I usually need to consult the online documentation for all this myself, so do not be afraid to dig into it.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jul 2021 09:34:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-07-06T09:34:19Z</dc:date>
    <item>
      <title>Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751049#M22516</link>
      <description>&lt;P&gt;Hello friends -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can any one please help with the log cleanup script&lt;/P&gt;
&lt;P&gt;I need your help with the Auto log cleanup script for the maintenance of our sas servers. am totally new to unix scripting. can anyone please assist with the cleanup script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to keep the log files 2 months in the /logs directory and any files older than 2 months has to go to the Backup directory and in the Backup directory&amp;nbsp; files should reside for 6 months&amp;nbsp; and any log files older&amp;nbsp; than 6 months should be deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want this script should perform this cleanup activity in all servers in different /log file locations of the server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would really appreciate if you can help with the script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you all in advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 19:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751049#M22516</guid>
      <dc:creator>sasprofile</dc:creator>
      <dc:date>2021-06-29T19:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751050#M22517</link>
      <description>&lt;P&gt;You could probably do this using a couple find commands, something like:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;find &amp;lt;log-path&amp;gt; -type f -mtime +60 -exec mv {} &amp;lt;backup-path&amp;gt; \;
find &amp;lt;backup-path&amp;gt; -type f -mtime +180 -delete&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;You could put that in a script and schedule it via cron to run regularly. If you run the command without the actions (i.e. no -delete and no -exec mv {} &amp;lt;backup-path \;) it will return the files it would take the action on.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 19:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751050#M22517</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2021-06-29T19:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751059#M22518</link>
      <description>&lt;P&gt;Thank you gwootton for prompt response..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Actually I found below find commands...but&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;find /sas/install/config/Lev1/Logs -maxdepth 1 -mtime +60 -type f -exec mv "{}" /backup \;&lt;BR /&gt;find /backup -maxdepth 1 -mtime +180 -type f -exec rm "{}" \;&lt;/P&gt;
&lt;P&gt;find /sas/install/config/Lev1/Web/WebServer/logs -maxdepth 1 -mtime +60 -type f -exec mv "{}" /sashome/M6_install/config/Lev1/Web/WebServer/logs/backup_062821 \;&lt;BR /&gt;find /sashome/M6_install/config/Lev1/Web/WebServer/logs/backup_062821 -maxdepth 1 -mtime +180 -type f -exec rm "{}" \;&lt;/P&gt;
&lt;P&gt;find /sas/install/config/Lev1/Web/Logs/SASServer1_1 -maxdepth 1 -mtime +60 -type f -exec mv "{}" /sashome/M6_install/config/Lev1/Web/Logs/SASServer1_1/backup_062821 \;&lt;BR /&gt;find /sashome/M6_install/config/Lev1/Web/Logs/SASServer1_1/backup_062821 -maxdepth 1 -mtime +180 -type f -exec rm "{}" \;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but am looking for the script with adding some email messages for each action taking place. find in conjunction with mv or rm. But for every find there must be a communication to sas admin telling what has been done&lt;/P&gt;
&lt;P&gt;Script servse the purpose in this case but what is missing the communication and not dealing with the error condition like a situation when there's not enough disk space on the target file system. And also not handling overwriting the file names when moving the file from sources to destinations&lt;/P&gt;
&lt;P&gt;I need below three things :&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;1)need to add comments line for each find command action &lt;BR /&gt;2)need to add send email for each action &lt;BR /&gt;3) need to add one more condition--- compression of the file after a month&lt;BR /&gt;4) also u need to know the size of the file moved from source to destination&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and also I need to have a new file name when moving from source to destination&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;The new name is necessary to avoid overwriting. The new naming convention should reflect the old name + server name + date of the activity,This is necessary since every things goes to same file system And names has to be unique to avoid overwriting&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Basically it is a rotation of the log files to compress after a month , followed by moving and then removing&lt;/P&gt;
&lt;P&gt;If u do not give new name, it will overwriting in the old file,It us good practice to have any new file with name having time stamp.&lt;/P&gt;
&lt;P&gt;That way when we need those files in future we can track them easily&lt;/P&gt;
&lt;P&gt;So new file name=old name.time stamp&lt;/P&gt;
&lt;P&gt;The whole idea of this practice is that I will be retaining these log file for a year is that i may need them&lt;/P&gt;
&lt;P&gt;My opinion is each month. In each folder, compress, tar the previous month's logs&lt;/P&gt;
&lt;P&gt;Example; xxxlog-202106.tar.zip at the end of this month&lt;/P&gt;
&lt;P&gt;Compression stays in side the source side&lt;/P&gt;
&lt;P&gt;After the compression the directory will create a one single file which will be moving after three months&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;One single file will be Xxxxlog-20320631.targz&lt;BR /&gt;And this file will be moved to /log at the end of December &lt;BR /&gt;And should have the same name as it is&lt;/P&gt;
&lt;P&gt;But should go to the directory for the relevant server inside /log&lt;BR /&gt;/log/metadata/xxxlog202106.targz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would really appreciate your help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 20:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751059#M22518</guid>
      <dc:creator>sasprofile</dc:creator>
      <dc:date>2021-06-29T20:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751068#M22520</link>
      <description>It sounds like you have a good idea of what you want your shell script to do, which is a good starting point.&lt;BR /&gt;&lt;BR /&gt;I don't have a sample program that meets all these requirements, but these are all things that can be done in shell scripting. &lt;BR /&gt;&lt;BR /&gt;You can use the date command to create a timestamp, maybe as an environment variable and use that as part of your mv command. You could use output redirection to write some information to a log file for your script, the mail command to send an email. Perhaps instead of using the -exec option of the find command you use find to get a list of files you want to do something with and then for each one write a line to your log, perform an action, etc.&lt;BR /&gt;&lt;BR /&gt;I would recommend reading up on shell scripting and doing a web search on the individual things you are trying to do in that script for more information on different ways to accomplish them.</description>
      <pubDate>Tue, 29 Jun 2021 21:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751068#M22520</guid>
      <dc:creator>gwootton</dc:creator>
      <dc:date>2021-06-29T21:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751071#M22521</link>
      <description>&lt;P&gt;Yeah I have some idea about my requirement what the shell script should do, but unfortunately i don't have any idea at all on shell scripting. The find commands also i&amp;nbsp; which sent earlier&amp;nbsp; i found it from google, if anyone can help with my requirement that would be really a big help.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 21:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751071#M22521</guid>
      <dc:creator>sasprofile</dc:creator>
      <dc:date>2021-06-29T21:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751362#M22526</link>
      <description>&lt;P&gt;Learning how to write shell scripts isn't really a SAS problem so you will probably find better help on websites devoted to this. Surely your company will have IT people skilled at this and who can help you to come up to speed or who you can ask to write the script for you. I know mine does and I'd be asking them to do the shell scripting for me as like you I know very little about it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 20:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751362#M22526</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-06-30T20:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751489#M22530</link>
      <description>&lt;P&gt;1. I see that you want a rotation of log. Have a look at the UNIX logrotate utility available is most Unix/Linux distributions.&lt;/P&gt;
&lt;P&gt;2.The Unix/Linux administrators should be able to help.&lt;/P&gt;
&lt;P&gt;3. I fully understand your not knowing shell scripting. Better to learn but not worry.&amp;nbsp; The expectations from SAS Administrators are a&amp;nbsp; growing unrealistically&amp;nbsp; &amp;nbsp;high these days depending upon the environment without much of a career progression.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 15:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/751489#M22530</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-07-01T15:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/752241#M22550</link>
      <description>&lt;P&gt;As soon as you start doing administrator work, Maxim 15 (Know Your Playing Field) turns from a strong recommendation into a requirement.&lt;/P&gt;
&lt;P&gt;Knowing at least the basics of bash scripting (creation and use of environment variables, conditional execution, regular expressions, writing to and reading from files, piping, just to name a few) is a must.&lt;/P&gt;
&lt;P&gt;You also need to get a grasp on the important UNIX utilities like find, grep, ls, ps. Maxim 6 (Google Is Your Friend) is a big helper in this respect.&lt;/P&gt;
&lt;P&gt;Since I do not have to do shell scripting often, I usually need to consult the online documentation for all this myself, so do not be afraid to dig into it.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 09:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/752241#M22550</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-06T09:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/825436#M24726</link>
      <description>&lt;P&gt;Hello - Did you have luck in completing the script for SAS log purging? I am also looking at options to set up an automatic SAS LOG purging job to clean up the logs periodically on the windows server. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 13:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/825436#M24726</guid>
      <dc:creator>ashasupriya</dc:creator>
      <dc:date>2022-07-26T13:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Auto Cleanup script for log files</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/825519#M24736</link>
      <description>&lt;P&gt;On Windows, if all you want to do is remove orphan SAS WORK libraries then just schedule the cleanup tool in Windows Task Scheduler:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASKiwi_0-1658866367167.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73749i641ED400F2D9A361/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASKiwi_0-1658866367167.png" alt="SASKiwi_0-1658866367167.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2022 20:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Auto-Cleanup-script-for-log-files/m-p/825519#M24736</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-07-26T20:15:11Z</dc:date>
    </item>
  </channel>
</rss>

