<?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: How to trim/remove a file which is alway open for writing in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443402#M8519</link>
    <description>The only solution I can think of to handle this would be with an interprocess pipe file (prwxrwxrwx).  In this case your current process writes to this pipe file and another process actually does the logging, trimming, etc.  This special file type has the capability of having one end open with the other end closed.  The process receiving and processing the data needs to be solid code and I strongly recommend some form of automatic periodic monitoring of the 'catcher' process also.</description>
    <pubDate>Thu, 07 Sep 2000 10:08:08 GMT</pubDate>
    <dc:creator>Tim Malnati</dc:creator>
    <dc:date>2000-09-07T10:08:08Z</dc:date>
    <item>
      <title>How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443396#M8513</link>
      <description>Greetings!&lt;BR /&gt; &lt;BR /&gt;I have an application running on HP-UX which is started in background and I&lt;BR /&gt;redirect its stdout and stderr to a file.&lt;BR /&gt; &lt;BR /&gt;Its behaviour can be simulated by this script:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;yes | tr "y012" "00" &amp;gt; big_big_file&lt;BR /&gt; &lt;BR /&gt;big_big_file is always growing.&lt;BR /&gt; &lt;BR /&gt;When I try on the Korn Shell:&lt;BR /&gt; &lt;BR /&gt;&amp;gt; big_big_file&lt;BR /&gt; &lt;BR /&gt;THe file is only apparently put to length zero, because after a new write it&lt;BR /&gt;gains again its previous size. If I try to remove it, the space available on&lt;BR /&gt;the filesystem keeps reducing. It is only released when I kill the process.&lt;BR /&gt; &lt;BR /&gt;How can I handle this situation?&lt;BR /&gt; &lt;BR /&gt;Note: I have this problen on HP-UX but I believe its the same on any unix...&lt;BR /&gt; &lt;BR /&gt;Thanks in advance for you help,&lt;BR /&gt; &lt;BR /&gt;Kind Regards,&lt;BR /&gt; &lt;BR /&gt;Rui.&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Sep 2000 08:03:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443396#M8513</guid>
      <dc:creator>Rui Vilao</dc:creator>
      <dc:date>2000-09-07T08:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443397#M8514</link>
      <description>Without getting your application to close the file I'm not sure that you can. Are you not able to stop/restart this process on a regular basis?&lt;BR /&gt;&lt;BR /&gt;If it's some sort of log file and you are not interested in the contents, can you use /dev/null instead?</description>
      <pubDate>Thu, 07 Sep 2000 08:07:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443397#M8514</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2000-09-07T08:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443398#M8515</link>
      <description>Rui,&lt;BR /&gt;&lt;BR /&gt;The problem is, that the process with the file open has a file pointer than points a long way into the file. Thus when you truncate it, althought the files length is now 0, the original process still has it's pointer somewhere else. When it next writes to the file, that's where it's going to write. Unless the process can do a lseek() to the end of the file (which will now be at byte 0), it's always going to write to where it thinks the end is.&lt;BR /&gt;&lt;BR /&gt;There is 1 piece of good news however. Because you've truncated the file, the file will probably now be a sparse file.&lt;BR /&gt;&lt;BR /&gt;So, if you do 'll &lt;FILE&gt;' and 'du -k &lt;FILE&gt;' you'll see that the size is completely different (btw du -k returns in 1k blocks). When the process does it's write to the end of the file, as the rest of the file doesn't exist, the O/S won't actually fill in all the nulls. The inode just keeps track that they should really be there.&lt;BR /&gt;&lt;BR /&gt;However, if  you backup/restore or copy the file, the nulls will be filled it (unless you use frecover with the -s option).&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Thu, 07 Sep 2000 08:12:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443398#M8515</guid>
      <dc:creator>Andy Monks</dc:creator>
      <dc:date>2000-09-07T08:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443399#M8516</link>
      <description>Use cat /dev/null &amp;gt; big.big.file&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Sep 2000 08:34:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443399#M8516</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-09-07T08:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443400#M8517</link>
      <description>Thanks John and Andy.&lt;BR /&gt;&lt;BR /&gt;You are both right. I looks like I don?t have much&lt;BR /&gt; choices...&lt;BR /&gt;&lt;BR /&gt;I can not stop my application on a regular basis... It&lt;BR /&gt;run 24h a day... (it runs on a MC/SG cluster!).&lt;BR /&gt;The application write trace info  to stdout and stderr...&lt;BR /&gt;It should not... but it does!&lt;BR /&gt;Redirecting it to /dev/null is not the best solution either&lt;BR /&gt;because then I loose my trace info...&lt;BR /&gt;&lt;BR /&gt;Andy, you are right when I run:&lt;BR /&gt;&amp;gt;  big_big_file &lt;BR /&gt;&lt;BR /&gt;The space on the filesystem is released. But may be it&lt;BR /&gt;is not a good to have such a weird situation on a&lt;BR /&gt;HA system...&lt;BR /&gt;&lt;BR /&gt;Chris,&lt;BR /&gt;Your suggestion is the same as &amp;gt;  big_big_file &lt;BR /&gt;Thanks anyway...&lt;BR /&gt;&lt;BR /&gt;More hints?</description>
      <pubDate>Thu, 07 Sep 2000 09:26:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443400#M8517</guid>
      <dc:creator>Rui Vilao</dc:creator>
      <dc:date>2000-09-07T09:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443401#M8518</link>
      <description>Rui,&lt;BR /&gt;&lt;BR /&gt;It's possible (but not a good idea), that a program could be run as root, that will reset the filepointer of another process. (slightly friendlier than adb!). However, as it would have to work off the pid, if the process died and was restarted as another pid, then something else took the original pid, you could be in trouble.&lt;BR /&gt;&lt;BR /&gt;Let me see how easy (or not) this is to write. Are we just talking about stdio/out/err?</description>
      <pubDate>Thu, 07 Sep 2000 09:56:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443401#M8518</guid>
      <dc:creator>Andy Monks</dc:creator>
      <dc:date>2000-09-07T09:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443402#M8519</link>
      <description>The only solution I can think of to handle this would be with an interprocess pipe file (prwxrwxrwx).  In this case your current process writes to this pipe file and another process actually does the logging, trimming, etc.  This special file type has the capability of having one end open with the other end closed.  The process receiving and processing the data needs to be solid code and I strongly recommend some form of automatic periodic monitoring of the 'catcher' process also.</description>
      <pubDate>Thu, 07 Sep 2000 10:08:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443402#M8519</guid>
      <dc:creator>Tim Malnati</dc:creator>
      <dc:date>2000-09-07T10:08:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443403#M8520</link>
      <description>Hi Rui,&lt;BR /&gt;&lt;BR /&gt;Ok, I can write a small program to reset the file pointers of another process (assuming you just want stdin/out/err done.&lt;BR /&gt;&lt;BR /&gt;So, what I need from you, is the release of hp-ux your running and if hpux 11, if it's 32 or 64bit.</description>
      <pubDate>Thu, 07 Sep 2000 10:36:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443403#M8520</guid>
      <dc:creator>Andy Monks</dc:creator>
      <dc:date>2000-09-07T10:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443404#M8521</link>
      <description>Again, thanks a lot for your contribution!&lt;BR /&gt; &lt;BR /&gt;Andy, I could indeed try your suggestion of having a process which reset the file&lt;BR /&gt;pointers of another process. It is probably not the best/cleanest solution...&lt;BR /&gt;I have to tell you that I am not starting only one process like this...&lt;BR /&gt;Our application consists of more or less 10 processes...&lt;BR /&gt;I hope it will not be too much work for you...&lt;BR /&gt;But since our application has a Solaris porting... The problem would still remain unsolved&lt;BR /&gt;on this platform.&lt;BR /&gt;Do you it is good solution to use "&amp;gt; big_big_file" because this will at least&lt;BR /&gt;prevent from filling the filesystem. Do you see any other problem than ls&lt;BR /&gt;returning the wrong size?&lt;BR /&gt; &lt;BR /&gt;Btw our current OS is 10.20 but we are migrating to 11.00 (64 bits).&lt;BR /&gt; &lt;BR /&gt;Tim, could you detail a bit your solution?&lt;BR /&gt; &lt;BR /&gt;Thanks,&lt;BR /&gt; &lt;BR /&gt;Rui&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Sep 2000 12:41:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443404#M8521</guid>
      <dc:creator>Rui Vilao</dc:creator>
      <dc:date>2000-09-07T12:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443405#M8522</link>
      <description>Rui,&lt;BR /&gt;&lt;BR /&gt;I was looking at Tim's suggestion and assuming you can redirect the output you could create a couple of named pipes (2 for each process) and then have something else reading from them.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;mknod /dev/pipe1_out p &lt;BR /&gt;mknod /dev/pipe1_err p&lt;BR /&gt;&lt;BR /&gt;Then do :-&lt;BR /&gt;&lt;BR /&gt;yourapp &amp;gt; /dev/pipe1_out 2&amp;gt;/dev/pipe1_err&lt;BR /&gt;&lt;BR /&gt;Then just have 2 processes writing it to a file :-&lt;BR /&gt;&lt;BR /&gt;cat &amp;lt; /dev/pipe1_out &amp;gt; /tmp/file1.out&lt;BR /&gt;cat &amp;lt; /dev/pipe1_err &amp;gt; /tmp/file1.err&lt;BR /&gt;&lt;BR /&gt;That way, you can stop the cat processes anytime, delete the file and restart them&lt;BR /&gt;&lt;BR /&gt;Btw, you MUST have the cat processes running as otherwise the pipe will fill up and the application writing to it, might get upset.</description>
      <pubDate>Thu, 07 Sep 2000 13:09:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443405#M8522</guid>
      <dc:creator>Andy Monks</dc:creator>
      <dc:date>2000-09-07T13:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443406#M8523</link>
      <description>Basically Andy has it right.  cat -u might be better where no buffering will take place.  You can also run the data into a single named pipe using 2&amp;gt;&amp;amp;1 if the application or script at the other end can handle the mixture.  &lt;BR /&gt;&lt;BR /&gt;Named pipes are supported by a lot more than just shell scripts and C routines.  A variety of database engines also support them allowing you to channel the data directly into a database.  With some cute manipulation you can even setup a service port and receive and redirect data from another machine into a daemon process without using socket code.&lt;BR /&gt;&lt;BR /&gt;Andy's caution is on the money.  A named pipe accumulates data just like any other file if the process on the other end is not extracting the data from it.  Depending on your process, this could be quite a bit very quickly.  Usually I have a cron job setup to verify the catcher process is running and restart it if it's not (with some additional flags to handle shutdown periods).</description>
      <pubDate>Thu, 07 Sep 2000 19:09:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443406#M8523</guid>
      <dc:creator>Tim Malnati</dc:creator>
      <dc:date>2000-09-07T19:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443407#M8524</link>
      <description>Just a thought:&lt;BR /&gt;&lt;BR /&gt;Try symbolic link. i.e.,&lt;BR /&gt;&lt;BR /&gt;touch big_big_file_1 big_big_file_2&lt;BR /&gt;ln -s big_big_file_1 big_big_file&lt;BR /&gt;&lt;BR /&gt;Later, you do&lt;BR /&gt;rm big_big_file; ln -s big_big_file_2 big_big_file&lt;BR /&gt;&lt;BR /&gt;and examine big_big_file_1 then make its size zero for next use or make a new file for the next switch.&lt;BR /&gt;&lt;BR /&gt;You can even automate it, if you have enough disk space or delete old logs in time.&lt;BR /&gt;&lt;BR /&gt;Hope this will work (I am not so sure about it).  I tried with a simple echo "line" &amp;gt;&amp;gt; tst.log enndless loop script and it seems worked there.</description>
      <pubDate>Mon, 11 Sep 2000 13:36:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443407#M8524</guid>
      <dc:creator>Felix J. Liu</dc:creator>
      <dc:date>2000-09-11T13:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to trim/remove a file which is alway open for writing</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443408#M8525</link>
      <description>Just a thought:&lt;BR /&gt;&lt;BR /&gt;Try symbolic link. i.e.,&lt;BR /&gt;&lt;BR /&gt;touch big_big_file_1 big_big_file_2&lt;BR /&gt;ln -s big_big_file_1 big_big_file&lt;BR /&gt;&lt;BR /&gt;Later, you do&lt;BR /&gt;rm big_big_file; ln -s big_big_file_2 big_big_file&lt;BR /&gt;&lt;BR /&gt;and examine big_big_file_1 then make its size zero for next use or make a new file for the next switch.&lt;BR /&gt;&lt;BR /&gt;You can even automate it, if you have enough disk space or delete old logs in time.&lt;BR /&gt;&lt;BR /&gt;Hope this will work (I am not so sure about it).  I tried with a simple echo "line" &amp;gt;&amp;gt; tst.log enndless loop script and it seems worked there.</description>
      <pubDate>Mon, 11 Sep 2000 13:37:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-trim-remove-a-file-which-is-alway-open-for-writing/m-p/2443408#M8525</guid>
      <dc:creator>Felix J. Liu</dc:creator>
      <dc:date>2000-09-11T13:37:17Z</dc:date>
    </item>
  </channel>
</rss>

