AIX-ksh script ends unexpectedly


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AIX-ksh script ends unexpectedly
# 1  
Old 01-12-2012
AIX-ksh script ends unexpectedly

Hi,

I have a ksh script running on AIX 5.3 which has sometimes a bizarre behaviour.
The script runs a child script like follow.
Code:
trap 'rm -f /tmp/res.log;exit 0' 2 15
run_child.sh > /tmp/res.log 2>&1
echo "run_child.sh is terminated"
next instructions...
rm -f /tmp/res.log

sometimes, the echo and next instructions are never proceeded.
if you set -x the script, you can see the last instruction is
Code:
+ run_child.sh > /tmp/res.log 2>&1

if you trace run_child.sh, you can see that it seems to go fine as i put an echo just before his last instruction (exit 0), and that i can see the result of the echo in the log.

So I'm searching here because i don't know what happen really.
This is not systematic but arrives sometimes (10% of executions)

any ideas ?

Moderator's Comments:
Mod Comment Please use code tags, thanks. Moving that thread to the shell scripting area.

Last edited by zaxxon; 01-12-2012 at 09:22 AM.. Reason: code tags
# 2  
Old 01-13-2012
If you didn't have the exit 0 in the trap, I think it will continue.
Try looking at this - Unix - Signals and Traps
# 3  
Old 01-13-2012
Quote:
Originally Posted by giannicello
If you didn't have the exit 0 in the trap, I think it will continue.
Try looking at this -
I'm sure that it do not enter in the trap as file is not removed.
If it enters in the trap, the exit is normal after removing the tmp file.
# 4  
Old 01-13-2012
How is the calling script being run? Is it on a terminal connection which might timeout or break?
# 5  
Old 01-16-2012
No, this is batch mode, there is no timemout, child is being proceeded in less than 2 seconds before problem arrives.
# 6  
Old 01-16-2012
How is the parent script being run?
What is in the child script?
# 7  
Old 01-16-2012
Parent script is run with HP Operation Manager with root user and a process named opcle
Child script is collecting information in a Oracle database and then ends with an output file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find a file which are not ends with ".zip" and which are ends with "*.log*" or "*.out*"?

I am new to bash/shell scripting. I want to find all the files in directory and subdirectories, which are not ends with “.zip” and which are contains in the file name “*.log*” or “*.out*”. I know below command to get the files which ends with “.log”; but I need which are not ends with this... (4 Replies)
Discussion started by: Mallikgm
4 Replies

2. Shell Programming and Scripting

Execution of KSH after the Other ENDS

I have couple of scripts which I may have to execute one after the other. The Script1 creates trg files and second sciprt need to look for this trg file and proces further. I read in the forum that (./test1.sh && ./test2.sh) would work. Can you please let me know how do i use this where I need to... (3 Replies)
Discussion started by: Sukruth Kumar
3 Replies

3. Shell Programming and Scripting

[Solved] AIX ksh script -d <- what does it mean?

I'm looking at a line in a script: && DRROOT="/dir1" || DRROOT="/dir2" I'm trying to understand it. Is there a "-d" command and is it seeing if /dir1 exists and, if so, set an environment variable named DRROOT to "/dir1", else set DRROOT to "/dir2" ? Thanks, -dog ---------- Post... (0 Replies)
Discussion started by: landog
0 Replies

4. Shell Programming and Scripting

Aix .ksh for loop script.

Hi, I'm trying to write a for loop to run through a list of servers and for each server copy a file to a backup file. But I can't seem to get it to run through my server list. It work for individual servers, please see below. #!/bin/ksh SSH_USERID=khcuser webservers="server1 server2" ... (2 Replies)
Discussion started by: elmesy
2 Replies

5. Shell Programming and Scripting

AIX .ksh script freezes when using the mail -s command

Hello I am trying to send an email when a .KSH script is run on an AIX Machine. This email will only include a subject line that is made up of variables from within the script, and is as follows: CURRENT_DATE=`date +%Y%m%d` TIME=`date` ADMIN="myname@domain.com" date block () { ... (4 Replies)
Discussion started by: jimbojames
4 Replies

6. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

7. Shell Programming and Scripting

Script - How to automatically start another process when the previous process ends?

Hi all, I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this: 1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently. 2) So I loaded datafile A... (10 Replies)
Discussion started by: luna_soleil
10 Replies

8. Shell Programming and Scripting

script unexpectedly terminating

I now that this isnt the greatest code around. Im a network guy by trade not a programer .. but needed something to compare config files ... Anyway ... intermittently, the program terminates. Ive been looking at the code for a week trying to figure it out and Im stumped. Can anyone provide... (0 Replies)
Discussion started by: popeye
0 Replies

9. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

10. Shell Programming and Scripting

ksh script to analyze log files on AIX 5.2

Hi, I have written a script that traps errors on different servers from the log files based on the current system date. The trapped errors are written to a file and file is sent as an attachment to an email. I would like to run this script for every 2hrs. when i run the script from the second... (0 Replies)
Discussion started by: itzcoolbuddy
0 Replies
Login or Register to Ask a Question