<?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: log file script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582367#M924445</link>
    <description>Thanks for the response but both scripts are a little too complicated. Does anyone have a simpler scripts that will do what I asking for. Once again, I just need something that I can run from any directory, rename any logfile to *.(date), null  the logfile. Hope this makes a little sense. Le tme know if anyone needs more info. Any help will be greatly appreciated.</description>
    <pubDate>Thu, 20 Sep 2001 13:55:00 GMT</pubDate>
    <dc:creator>sanjit</dc:creator>
    <dc:date>2001-09-20T13:55:00Z</dc:date>
    <item>
      <title>log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582364#M924442</link>
      <description>Hello everyone,&lt;BR /&gt;&lt;BR /&gt;Can someone please assist me with writing a log script. I'm very new to Unix and defintely new to writing scripts. I need to be able to run a script that I can run from any directory, that will simply take my current log file, rename it to .(date). and then clean out the original file so it can be used the next day. My big thing here is for the script to be able to run from any directory and be able to pick up any type of lig files. Any help will be greatly appreciated here. Is someone has a sample script that I can use would also be very helpful. Thanks and have a nice day.</description>
      <pubDate>Thu, 20 Sep 2001 12:33:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582364#M924442</guid>
      <dc:creator>sanjit</dc:creator>
      <dc:date>2001-09-20T12:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582365#M924443</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The following processes all the log files defined in syslog.conf - sorry if it's heavy going, but will give you an idea:&lt;BR /&gt;&lt;BR /&gt;======================================&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;#       Set IFS to &lt;SPACE&gt;&lt;TAB&gt;&lt;NEWLINE&gt;&lt;BR /&gt;IFS='   &lt;BR /&gt;'&lt;BR /&gt;export IFS&lt;BR /&gt;PATH=/sbin:/usr/sbin:/usr/bin&lt;BR /&gt;export PATH&lt;BR /&gt;SHELL=/usr/bin/sh&lt;BR /&gt;export SHELL&lt;BR /&gt;&lt;BR /&gt;CONFIG="${CONFIG:-/etc/syslog.conf}"&lt;BR /&gt;SYSLOGPID="${SYSLOGPID:-$(&amp;lt; /etc/syslog.pid)}"&lt;BR /&gt;&lt;BR /&gt;#echo CONFIG is $CONFIG&lt;BR /&gt;#echo SYSLOGPID is $SYSLOGPID&lt;BR /&gt;&lt;BR /&gt;today=$(date +%a)&lt;BR /&gt;&lt;BR /&gt;typeset -i i=0 file=0&lt;BR /&gt;&lt;BR /&gt;#       Now get paths of all syslog files.&lt;BR /&gt;grep -v -e '^[  ]*#' -e '^[     ]*$' "${CONFIG}"                        |&lt;BR /&gt;        while read selector action ; do&lt;BR /&gt;                if [[ -f "${action}" ]] ; then&lt;BR /&gt;                        files[file]="${action}"&lt;BR /&gt;                        let file=file+1&lt;BR /&gt;                fi&lt;BR /&gt;        done&lt;BR /&gt;&lt;BR /&gt;if [[ file -gt 0 ]] ; then&lt;BR /&gt;        let i=0&lt;BR /&gt;        while [[ i -lt file ]] ; do&lt;BR /&gt;                rm -f "${files[i]}.${today}" "${files[i]}.${today}.Z"&lt;BR /&gt;                if mv "${files[i]}" "${files[i]}.${today}" ; then&lt;BR /&gt;                        files[i]="${files[i]}.${today}"&lt;BR /&gt;                else&lt;BR /&gt;                        files[i]=""&lt;BR /&gt;                fi&lt;BR /&gt;                let i=i+1&lt;BR /&gt;        done&lt;BR /&gt;        kill -1 $SYSLOGPID&lt;BR /&gt;        let i=0&lt;BR /&gt;        while [[ i -lt file ]] ; do&lt;BR /&gt;                if [[ "" != "${files[i]}" ]] ; then&lt;BR /&gt;                        compress "${files[i]}"&lt;BR /&gt;                fi&lt;BR /&gt;                let i=i+1&lt;BR /&gt;        done&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;=======================================&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin&lt;BR /&gt;&lt;BR /&gt;&lt;/NEWLINE&gt;&lt;/TAB&gt;&lt;/SPACE&gt;</description>
      <pubDate>Thu, 20 Sep 2001 12:57:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582365#M924443</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-09-20T12:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582366#M924444</link>
      <description>Hi ! For cutomized scripts you maybe want to use a special directory. I usually put those scripts into /sbin/scripts. &lt;BR /&gt;To fill a log from your script do:&lt;BR /&gt;&lt;YOUR_SCRIPT&gt;&amp;amp;1 &amp;gt;&amp;gt; &lt;YOUR_LOGFILE&gt;&lt;BR /&gt;For creating logfiles with timestamps use the following within your script: (man date ;-)&lt;BR /&gt;----snip-------&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;TIMESTAMP=`date +&lt;YOUR_NEEDED_FORMAT&gt;`&lt;BR /&gt;cp ${LOGFILE} ${LOGFILE}.${TIMESTAMP}&lt;BR /&gt;&amp;gt; ${LOGFILE}&lt;BR /&gt;# set logfile&lt;BR /&gt;# copy old logfile to logfile with timestamp&lt;BR /&gt;# and clear the old logfile to fill it with new&lt;BR /&gt;# informations.&lt;BR /&gt;----snip-------&lt;BR /&gt;To run a script form any position do the following: (You may add this entry to your .profile)&lt;BR /&gt;----snip-------&lt;BR /&gt;PATH=$PATH:/sbin/scripts&lt;BR /&gt;----snip-------&lt;BR /&gt;Never put a . into PATH, it is a potential security breach.&lt;BR /&gt;&lt;BR /&gt;NOTE: For handling logfiles, the tool logrotate has been ported to HP-UX.&lt;BR /&gt;(See &lt;A href="http://hpux.cs.utah.edu)" target="_blank"&gt;http://hpux.cs.utah.edu)&lt;/A&gt;&lt;BR /&gt;Hope this helps a bit&lt;BR /&gt;RGDS, Holger&lt;/YOUR_NEEDED_FORMAT&gt;&lt;/YOUR_LOGFILE&gt;&lt;/YOUR_SCRIPT&gt;</description>
      <pubDate>Thu, 20 Sep 2001 13:15:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582366#M924444</guid>
      <dc:creator>Holger Knoppik</dc:creator>
      <dc:date>2001-09-20T13:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582367#M924445</link>
      <description>Thanks for the response but both scripts are a little too complicated. Does anyone have a simpler scripts that will do what I asking for. Once again, I just need something that I can run from any directory, rename any logfile to *.(date), null  the logfile. Hope this makes a little sense. Le tme know if anyone needs more info. Any help will be greatly appreciated.</description>
      <pubDate>Thu, 20 Sep 2001 13:55:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582367#M924445</guid>
      <dc:creator>sanjit</dc:creator>
      <dc:date>2001-09-20T13:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582368#M924446</link>
      <description>Hi Sanjit,&lt;BR /&gt;&lt;BR /&gt;This script doesn't do much error checking&lt;BR /&gt;&lt;BR /&gt;/Begin/&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;if [[ $# &amp;lt; 1 ]]&lt;BR /&gt;then&lt;BR /&gt;    echo "Usage: $0 logfile"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;TIMESTAMP=`date +%m%d%y`&lt;BR /&gt;echo "Copying $1 to $1.${TIMESTAMP}"&lt;BR /&gt;cp $1 $1.${TIMESTAMP}&lt;BR /&gt;echo "/dev/null $1.${TIMESTAMP}"&lt;BR /&gt;cat /dev/null &amp;gt; $1&lt;BR /&gt;&lt;BR /&gt;/End/&lt;BR /&gt;&lt;BR /&gt;what kind of log files are you trying to move, there are already good scripts available which do lots of things, the above script will just&lt;BR /&gt;copy the logfile to logfile.monthdayyear format (eg logfile.092001)&lt;BR /&gt;&lt;BR /&gt;-HTH&lt;BR /&gt;Ramesh</description>
      <pubDate>Thu, 20 Sep 2001 14:21:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582368#M924446</guid>
      <dc:creator>linuxfan</dc:creator>
      <dc:date>2001-09-20T14:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582369#M924447</link>
      <description>Hi Ramesh,&lt;BR /&gt;I'm trying to do this to any logfiles on any of my 30 systems that I have. I wonna be able to run this script from any directories also. Thanks for your help.</description>
      <pubDate>Thu, 20 Sep 2001 15:16:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582369#M924447</guid>
      <dc:creator>sanjit</dc:creator>
      <dc:date>2001-09-20T15:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582370#M924448</link>
      <description>Hi Sanjit,&lt;BR /&gt;&lt;BR /&gt;As long as you give the right permissions to this script and give the right logfile (complete path to the logfile) you should be able to run this script from anywhere on any logfile (provided you have the right permissions on the logfile).&lt;BR /&gt;&lt;BR /&gt;Like i said, if you are planning to do this for syslog, then there are better scripts like&lt;BR /&gt;&lt;BR /&gt;1. logrotate.sh &lt;BR /&gt;&lt;A href="http://www.introcomp.co.uk/examples/logrotate.html" target="_blank"&gt;http://www.introcomp.co.uk/examples/logrotate.html&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;2. rotatelog program by shaun Rowland (in Perl) &lt;BR /&gt;&lt;A href="http://www.interhack.net/projects/rotatelog" target="_blank"&gt;http://www.interhack.net/projects/rotatelog&lt;/A&gt; &lt;BR /&gt;(pretty nice) &lt;BR /&gt;&lt;BR /&gt;3. Rotate logs &lt;BR /&gt;&lt;A href="http://www.ginini.com.au/tools/rotatelogs/" target="_blank"&gt;http://www.ginini.com.au/tools/rotatelogs/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Does this answer your question?&lt;BR /&gt;&lt;BR /&gt;-Regards&lt;BR /&gt;Ramesh&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Sep 2001 15:34:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582370#M924448</guid>
      <dc:creator>linuxfan</dc:creator>
      <dc:date>2001-09-20T15:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582371#M924449</link>
      <description>Hi Sanjit,&lt;BR /&gt;Lets take a look. You have 30 systems and do you want to run script on any systems? It will be pain after couple days. If you are able to remsh from one system to all other system then setup your script in one server. &lt;BR /&gt;In order to run from any directory you have to setup path in your .cshrc. Then you copy script in to that directory&lt;BR /&gt;#echo $PATH and choose appropriate directory where you can save your script.&lt;BR /&gt;Now lets take script from Ramesh and change little&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh &lt;BR /&gt;&lt;BR /&gt;if [[ $# &amp;lt; 1 ]] &lt;BR /&gt;then &lt;BR /&gt;echo "Usage: $0 logfile" &lt;BR /&gt;fi &lt;BR /&gt;TIMESTAMP=`date +%m%d%y` &lt;BR /&gt;&lt;BR /&gt;for SYSTEM in server1 server2 server3?? ; do&lt;BR /&gt;  echo "Copying $1 to $1.${TIMESTAMP}" &lt;BR /&gt;  remsh ${SYSTEM} cp $1 $1.${TIMESTAMP} &lt;BR /&gt;  remsh ${SYSTEM} echo "/dev/null $1.${TIMESTAMP}" &lt;BR /&gt;  remsh ${SYSTEM} cat /dev/null &amp;gt; $1 &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;/End/ &lt;BR /&gt;&lt;BR /&gt;If you have that script as cleanup then run&lt;BR /&gt;#cleanup /var/adm/syslog/mail.log&lt;BR /&gt;It will run on three server.&lt;BR /&gt;&lt;BR /&gt;Sachin</description>
      <pubDate>Thu, 20 Sep 2001 15:43:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582371#M924449</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2001-09-20T15:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: log file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582372#M924450</link>
      <description>Thank you all very much for all the help. You guys are wonderful and this helps us people new to Unix learn a lot from all this.</description>
      <pubDate>Thu, 20 Sep 2001 15:44:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/log-file-script/m-p/2582372#M924450</guid>
      <dc:creator>sanjit</dc:creator>
      <dc:date>2001-09-20T15:44:10Z</dc:date>
    </item>
  </channel>
</rss>

