<?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: Bourne Shell moving/copying  files ≥nerating date&amp;amp;time stamp in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642404#M722697</link>
    <description>Let me see if I get it right:&lt;BR /&gt;&lt;BR /&gt;- You receive files in  .../upload&lt;BR /&gt;- You like to copy these files to .../download while adding a timestamp to the name&lt;BR /&gt;- You move the file away then, so that the procedure can work again, if the fiel is send again &lt;BR /&gt;&lt;BR /&gt;??????&lt;BR /&gt;&lt;BR /&gt;Since you do this every minute, how do you ensure, that you do not copy a file that is still in transmission ?&lt;BR /&gt;Since you did choose one minute as a period, you seem to expect these files quite frequently, so how do you ensure, that the file is not being sent right between those two "find" statements (which means it will be moved without beinig copied first)?&lt;BR /&gt;&lt;BR /&gt;I would recommend to change the sending part in a way, that before a transmission of file "abc" it is checked if a file "abc.READY" exists, and if yes, the send is deleayed.&lt;BR /&gt;If "abc.READY" does not exist, you send "abc" and after the transmission you rename it "abc.READY" from the remote site.&lt;BR /&gt;&lt;BR /&gt;Change you find commands just to process *.READY files, add the suggestions of the first two responses, and I guess you will be more safe.&lt;BR /&gt;&lt;BR /&gt;Just my 2 cent&lt;BR /&gt;Volker &lt;BR /&gt;</description>
    <pubDate>Thu, 10 Jan 2002 16:57:37 GMT</pubDate>
    <dc:creator>Volker Borowski</dc:creator>
    <dc:date>2002-01-10T16:57:37Z</dc:date>
    <item>
      <title>Bourne Shell moving/copying  files ≥nerating date&amp;time stamp</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642399#M722692</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have a script that copies files every min&lt;BR /&gt;in cron if they are present.  Files can&lt;BR /&gt;be the same name and we do not want to over&lt;BR /&gt;write the file name but append the date and&lt;BR /&gt;time stamp.&lt;BR /&gt;&lt;BR /&gt;SCRIPT:&lt;BR /&gt;find /virtual/easttrust/upload -type f |xargs -i cp {} /hal/easttrust/download&lt;BR /&gt;find /virtual/easttrust/upload -type f |xargs -i mv {} /tmp&lt;BR /&gt;&lt;BR /&gt;For output I want this in both my directories:&lt;BR /&gt;&lt;BR /&gt;filename.date and time stamp&lt;BR /&gt;&lt;BR /&gt;Then I want to delete any files over 30 days&lt;BR /&gt;old so I don't get a disk full error.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Laurie</description>
      <pubDate>Thu, 10 Jan 2002 16:39:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642399#M722692</guid>
      <dc:creator>Laurie A. Krumrey</dc:creator>
      <dc:date>2002-01-10T16:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Bourne Shell moving/copying  files ≥nerating date&amp;time stamp</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642400#M722693</link>
      <description>find . -mtime +30 | xargs rm</description>
      <pubDate>Thu, 10 Jan 2002 16:42:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642400#M722693</guid>
      <dc:creator>Jeff Machols</dc:creator>
      <dc:date>2002-01-10T16:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Bourne Shell moving/copying  files ≥nerating date&amp;time stamp</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642401#M722694</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You can make use of this variable to have date and time stamp&lt;BR /&gt;&lt;BR /&gt;DATE=`/usr/bin/date '+%H%M'`&lt;BR /&gt;&lt;BR /&gt;-USA..&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jan 2002 16:44:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642401#M722694</guid>
      <dc:creator>Uday_S_Ankolekar</dc:creator>
      <dc:date>2002-01-10T16:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Bourne Shell moving/copying  files ≥nerating date&amp;time stamp</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642402#M722695</link>
      <description>Use date with the +format option (see the date man page), eg:&lt;BR /&gt;&lt;BR /&gt;EXT=`date +%Y%m%d-%H%M`&lt;BR /&gt;for FILE in `find /hal/easttrust/upload -type f` ; do&lt;BR /&gt;  cp $FILE /hal/easttrust/download/${FILE}.${EXT}&lt;BR /&gt;  mv $FILE /tmp/${FILE}.${EXT}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Then to remove the old files just use find with -mtime +30.  Maybe move the files to /tmp/old_upload or something instead of /tmp so you can limit the find command to those files only.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Steve</description>
      <pubDate>Thu, 10 Jan 2002 16:53:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642402#M722695</guid>
      <dc:creator>Steven Gillard_2</dc:creator>
      <dc:date>2002-01-10T16:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Bourne Shell moving/copying  files ≥nerating date&amp;time stamp</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642403#M722696</link>
      <description>Hi Laurie,&lt;BR /&gt;&lt;BR /&gt;The way i see it, you should first change the name of the files in the source directory (upload) to look like filename.date and then move them to the other directory. you can then put a cron job to delete all files older than 30 days.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Regds&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jan 2002 16:56:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642403#M722696</guid>
      <dc:creator>Sanjay_6</dc:creator>
      <dc:date>2002-01-10T16:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Bourne Shell moving/copying  files ≥nerating date&amp;time stamp</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642404#M722697</link>
      <description>Let me see if I get it right:&lt;BR /&gt;&lt;BR /&gt;- You receive files in  .../upload&lt;BR /&gt;- You like to copy these files to .../download while adding a timestamp to the name&lt;BR /&gt;- You move the file away then, so that the procedure can work again, if the fiel is send again &lt;BR /&gt;&lt;BR /&gt;??????&lt;BR /&gt;&lt;BR /&gt;Since you do this every minute, how do you ensure, that you do not copy a file that is still in transmission ?&lt;BR /&gt;Since you did choose one minute as a period, you seem to expect these files quite frequently, so how do you ensure, that the file is not being sent right between those two "find" statements (which means it will be moved without beinig copied first)?&lt;BR /&gt;&lt;BR /&gt;I would recommend to change the sending part in a way, that before a transmission of file "abc" it is checked if a file "abc.READY" exists, and if yes, the send is deleayed.&lt;BR /&gt;If "abc.READY" does not exist, you send "abc" and after the transmission you rename it "abc.READY" from the remote site.&lt;BR /&gt;&lt;BR /&gt;Change you find commands just to process *.READY files, add the suggestions of the first two responses, and I guess you will be more safe.&lt;BR /&gt;&lt;BR /&gt;Just my 2 cent&lt;BR /&gt;Volker &lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jan 2002 16:57:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642404#M722697</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2002-01-10T16:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Bourne Shell moving/copying  files ≥nerating date&amp;time stamp</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642405#M722698</link>
      <description>Hi Laurie,&lt;BR /&gt;&lt;BR /&gt;WRKFILE=/tmp/wrkfile.$$&lt;BR /&gt;&lt;BR /&gt;DT=`date +%Y%m%d%H%M`&lt;BR /&gt;&lt;BR /&gt;find /virtual/easttrust/upload -type f &amp;gt;$WRKFILE&lt;BR /&gt;while read file&lt;BR /&gt;do&lt;BR /&gt;BNAME=`basename $file`&lt;BR /&gt;cp $file /hal/easttrust/download/$BNAME.$DT&lt;BR /&gt;mv $file /tmp/download/$BNAME.$DT&lt;BR /&gt;done &amp;lt;$WRKFILE&lt;BR /&gt;&lt;BR /&gt;rm $WRKFILE&lt;BR /&gt;&lt;BR /&gt;# remove files older than 30 days&lt;BR /&gt;find /hal/easttrust/download -type f -mtime +30 | xargs rm&lt;BR /&gt;find /tmp/download -type f -mtime +30 | xargs rm&lt;BR /&gt;&lt;BR /&gt;# End script&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I don't see why you need a second copy of the file in /tmp but I'd choose to use a directory created just for that purpose (/tmp/download in my example).&lt;BR /&gt;&lt;BR /&gt;You can put DT=`date +%Y%m%d%H%M` in the while loop if you want the time each file is copied or leave it before the loop for all files to have the same date/time stamp (my preference).&lt;BR /&gt;&lt;BR /&gt;As Volker points out, you have other issues to consider.  Is a file busy? You may be able to use fuser to determine that but it could be busy for other reasons besides being written.  But since you move it after copying it, then as long as it isn't busy the next time the script runs you should be okay.&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;BR /&gt;Darrell</description>
      <pubDate>Thu, 10 Jan 2002 18:38:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bourne-shell-moving-copying-files-nerating-date-amp-time-stamp/m-p/2642405#M722698</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-01-10T18:38:00Z</dc:date>
    </item>
  </channel>
</rss>

