pjohns
9th April 2003, 17:32
Hello,

I've created the following script file to run Baan jobs across multi companies. But I'm having trouble in getting a log file created. The jobs run without error but nothing gets written to the log file. It's as if Unix is trying to pass the log file path as a parameter? Can anybody help?

Script file: -

BSE=/baan/bse
BSE_TMP=$BSE/tmp
PATH=$BSE/bin:$PATH:.
export PATH
export BSE BSE_TMP
TERM=vt100
export TERM
BAAN_EXTJOB=1
export BAAN_EXTJOB

su - batch502 -c "$BSE/etc/rc.startjob EDICOM /baan/bse/log/log.edicom"

wait
su - batch503 -c "$BSE/etc/rc.startjob EDICOM /baan/bse/log/log.edicom"
wait
su - batch501 -c "$BSE/etc/rc.startjob EDICO1 /baan/bse/log/log.edicom"

Regards

PJ

patvdv
9th April 2003, 17:51
PJ, If you want the output of the command line instruction to be logged into a log file, you need to redirect your standard output (STDOUT) and standard error (STDERR):

su - batch501 -c "$BSE/etc/rc.startjob EDICO1 >/baan/bse/log/log.edicom 2>&1"

pjohns
9th April 2003, 18:13
Pat,

Thanks for your reply.

We had tried what you suggested but this gave us an empty file.

What I'm after is an error log as a result of the job running. If you put the following line....: -

$BSE/etc/rc.startjob EDICOM /baan/bse/log/log.edicom


....into a file and run it you get the following in a log file: -

bpid:11328
sess:tcedi7205m000
sesn:1
info Direct Network Comm - 501
comp:501
stim:20020404110000
usti:20020404100000
etim:20020404110000
ueti:20020404100000
ssta:OK
jsta:OK

Cheers

PJ

victor_cleto
9th April 2003, 18:49
hummm, weirdo, what is happening at rc.startjob level is that if you give more than 1 parameter (JOB), then the 2nd parameter is set as BSH_JOBOK=$2

try this:
# make sure the file is writable by all Baan users
chown bsp:bsp /baan/bse/log/log.edicom
chmod 660 /baan/bse/log/log.edicom
# kick of job
su - batch502 -c "BSH_JOBOK=/baan/bse/log/log.edicom; export BSH_JOBOK; $BSE/etc/rc.startjob EDICOM"

Also, I don't know if Baan keeps overwiting the log (?) so, if that is true, you'll need to use a temp log and then do a cat ... >> to the final log.

NPRao
9th April 2003, 19:45
Try this-

ba6.2 -- -nodebug ttaad5203m000 2>${BSE_LOG}/${BSH_JOB}.${DATE_STAMPING} &

Make sure you have the correct file access permissions and also assign the proper values to those variables in CAPS.
BSE_LOG = $BSE/log or any log directory.
BSH_JOB= name of the job
DATE_STAMPING=date/time stamping if you like to track log of each execution

dnnslbrwn
10th April 2003, 17:53
Possibly also take the background ( & ) out of the rc.startjob. After the su command terminates, the wait might not see the BAAN job running for the other UNIX users.

Cheers,

-Dennis

NPRao
11th April 2003, 21:51
Dennis,

The advantage to use the wait after the job is set as a background is that, you can parse the log file to see if the job status is OK or Error. Based on the status you can use a email/page notifications.

I am not sure if wait looks for other users jobs or not. But I think in Unix all the job processes are owned by root.

Checking the man of wait-

wait(1) wait(1)

NAME
wait - await process completion

SYNOPSIS
wait [pid]

DESCRIPTION
If no argument is specified, wait waits until all processes (started
with &) of the current shell have completed, and reports on abnormal
terminations. If a numeric argument pid is given and is the process
ID of a background process, wait waits until that process has
completed. Otherwise, if pid is not a background process, wait exits
without waiting for any processes to complete.

Because the wait() system call must be executed in the parent process,
the shell itself executes wait without creating a new process (see
wait(2)).

Command-Line Arguments
wait supports the following command line arguments:

pid The unsigned decimal integer process ID of a command,
whose termination wait is to wait for.

WARNINGS
Some processes in a 2-or-more-stage pipeline may not be children of
the shell, and thus cannot be waited for.

SEE ALSO
csh(1), ksh(1), sh-posix(1), sh(1), wait(2).

STANDARDS CONFORMANCE
wait: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

Hewlett-Packard Company - 1 - HP-UX Release 11.00: October 1997


Please correct me if I am wrong.

dnnslbrwn
11th April 2003, 22:28
NPRao,

Ran a quick test from a second UNIX account:

su - dennisb -c "sleep 30"
wait

... and it waited for 30 seconds as I would expect. Then ran:

su - dennisb -c "sleep 30 & "
wait

... and control returned right away. I think that the 'su' is a wall that wait can not see over.

So, I would think that the program at the top of this discussion would be done almost right away and then the three jobs running at the same time would be fighting over the one filename without append.

Cheers,

-Dennis

NPRao
11th April 2003, 22:52
Dennis,

Thanks for the info. But we use Control-M to handle all our BaaN jobs and unix shell scripts etc.

We have our own custom made job activation script refined from rc.startjob scripts.


ZDATE=`date +%Y%m%d%H%M%S`

export BSE_LOG=$LMS_VAR/logs/jobs/$COMPANY
export BSH_JOBOK=${BSE_LOG}/${BSH_JOB}_${ZDATE}.$$
export DS_AS=$BSHELL
...
ba6.2 -- -nodebug ttaad5203m000 2>${BSE_LOG}/lmsjob_${BSH_JOB}.${ZDATE} &


Hence each job stream invokes a copy of this start script which starts the job/sessions, hence the probability of having the same date/time stamping is less and also that its followed by $$ the process id so our log files are very unique, hence we avoid the file locking or contesting between the processes.