Re: Oh where oh where is STDOUT



"Klaatu62" <klaatu62@xxxxxxxxxxx> writes:

OK I've researched this to death, and not found an answer...

We have about 500 scripts that are run out of TIVOLI job manager. Each
run causes the STDOUT to be redirected to a new file in a directory
that has the current date as it's name.

The problem is that when a job has run for several days, there is no
way other than grepping through thousands of STDLIST files in 3, 4, 10,
20 directories, looking for where the task is outputting.

I was thinking that there should be a way for the running script to
output the current name of its STDOUT. That way, I could do something
like:

echo "$0 running as of $date and outputting to $STDOUT">>$stdlogfile

It's a way. But a big problem with your naming scheme is that two
processes started at the same time (within one second) will have the
same output file. (Two processes with the same PID within the same
second should very rarely occur, but with the fast processors nowdays,
it's not totally impossible, if the kernel doesn't do anything special
to prevent it).

You should try to make up unique names for the output; something like:

output_name=$(mktemp $(date +%Y%m%dT%H%M%S)-${PID}-XXXXXX)

for example:

for PID in 101 102 103 104 105 101 102 103 104 105 ; do
( output_name=$(mktemp $(date +%Y%m%dT%H%M%S)-${PID}-XXXXXX) ;\
sleep 3 ; echo $output_name ) & done ; echo ''


20061019T070635-101-rkTioS
20061019T070635-101-vexGPR
20061019T070635-105-anFxmW
20061019T070635-104-TLNDHY
20061019T070635-105-Ca2xz0
20061019T070635-103-2TRhn0
20061019T070635-102-kTZjC1
20061019T070635-102-Eu8UD9
20061019T070635-103-QkRKR9
20061019T070635-104-f1wSU7


This way, when you want the output of a process, you can easily find
it by PID.

--
__Pascal Bourguignon__ http://www.informatimago.com/
The mighty hunter
Returns with gifts of plump birds,
Your foot just squashed one.
.



Relevant Pages

  • Re: Oh where oh where is STDOUT
    ... We have about 500 scripts that are run out of TIVOLI job manager. ... looking for where the task is outputting. ... I was thinking that there should be a way for the running script to ... output the current name of its STDOUT. ...
    (comp.unix.questions)
  • Re: Insert character at a fixed position of lines
    ... after a string) of the type ... In your scripts I am lost ... stdin and stdout is a file- ... three different uppercase letters. ...
    (comp.lang.python)
  • RE: STDOUT
    ... If one of the scripts has an error, ... First it doesn't check the syntax, ... if (!-e $progname) { ... how to redirect STDOUT and STDERR when doing backticks. ...
    (perl.beginners)
  • Oh where oh where is STDOUT
    ... We have about 500 scripts that are run out of TIVOLI job manager. ... way other than grepping through thousands of STDLIST files in 3, 4, 10, ... looking for where the task is outputting. ...
    (comp.unix.questions)
  • Re: Why stdin/stdout are two devices?
    ... I have written many scripts where stdout is, say, ... The two devices is also helpful in a CGI-type environment, where stdout ... and stderr goes to the error log. ...
    (comp.os.linux.misc)