Gil, excellent reply. Thank you. I didn't realize there was such a beast
as cron, but there it is in the manuals and there appears to be a lot of
info on it in the internet.

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:ibm-m...@bama.ua.edu] On
Behalf Of Paul Gilmartin
Sent: Friday, September 25, 2009 9:41 PM
To: IBM-MAIN@bama.ua.edu
Subject: Re: OMVS txt file problem

On Fri, 25 Sep 2009 17:31:01 -0500, Ward, Mike S wrote:

>Hello all, I'm kind of new to the OMVS world and I'd like a little help
>if possible. I have a directory in the OMVS segment that programs write
>their logs to.
>
This question is probably better asked on MVS-OE than on IBM-MAIN,
but I'll give it a try:

>How could I automate the ftping of those files to a windows ftp server
>for archive purposes then clear out the text file so that it can
>start fresh?
>
Suppose your transactions append their logs to "log.txt".  In your
crontab commands, call a script like:

# Create a second handle to the log:

    ln log.txt oldlog.txt ||
      { # somehow report error to process owner.  This most likely
        # happens because the previous day's log rotate failed, then:
        echo "rename of log failed" >&2
        exit 1;  }

# Create new log file and replace the active log file.
# Transactions which have opened the active log file will
# unknowingly continue to write to that file, now called
# oldlog.txt.  POSIX specification of mv guarantees tnat
# no starting transaction will fail to observe a log.txt:

    touch newlog.txt
    mv newlog.txt log.txt

# Wait long enough for transactions in progress to complete.
# Ugh.  Timing dependent.  There may be a better way.  Then
# FTP to Windows server; delete if successful:

    sleep 1000
    echo 'put oldlog.txt windows.log.txt
          quit' |
    ftp windows-server '(exit' ||
      { # Somehow report error to process owner, then.
        echo "ftp of log failed" >&2
        exit 1;  }

    rm oldlog.txt
    exit 0

If two transactions run concurrently, their records will appear
interleaved in the log file.  This can be avoided by either:

o Each transaction's buffering its log records and writing all
  to the log with a single call to write(), or

o Prefixing each record with a unique transaction ID and later
  sorting on that field,

or some combination of both.

This script should write nothing to stdout, and write to stderr
only if errors occur.  Crontab mails the combined content of
stdout and stderr to the process owner, but not if both are
empty.  So you'll get email notification of failure but not
of success.  If you want notification of success, add an
echo command before the "exit 0".

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
==========================
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity
to which they are addressed. If you have received this email in error please 
notify the system manager. This message
contains confidential information and is intended only for the individual 
named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please notify the 
sender immediately by e-mail if you
have received this e-mail by mistake and delete this e-mail from your system. 
If you are not the intended recipient
you are notified that disclosing, copying, distributing or taking any action in 
reliance on the contents of this
information is strictly prohibited.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to