Script Keeping Track of Itself


 
Thread Tools Search this Thread
Operating Systems AIX Script Keeping Track of Itself
# 1  
Old 08-26-2008
Script Keeping Track of Itself

Hi All
We have a WEB Based application running on the IBM AIX server. There is a EOD Job which runs a UNIX script containing EOD Jobs. Say If any job fails then we have to explicitly comment out the jobs which were successfully executed and then re run the same.

Is there any was by which we can automate it so that it keeps track of the job which is getting executed and say if it failed at some point, when I re run it, it should automatically start from the same point where it got failed?

Kindly help me on this.

Waiting for positive replies
# 2  
Old 08-26-2008
dear prashant,
you can do one thing but its bit tough..
you can add a check condition after each script..
i.e check the return code $?
if its not zero it should write that script name to a new file so that you can re run that new file..
# 3  
Old 08-26-2008
I will elaborate a bit on this. The original script is something like this::::

. ./runEod.sh 6000 $brn_num>> error.txt 2>&1
. ./runEod.sh 6001 $brn_num>> error.txt 2>&1
. ./runEod.sh 6002 $brn_num>> error.txt 2>&1
. ./runEod.sh 1010 $brn_num>> error.txt 2>&1
. ./runEod.sh 1070 $brn_num>> error.txt 2>&1
. ./runEod.sh 1071 $brn_num>> error.txt 2>&1
. ./runEod.sh 6003 $brn_num>> error.txt 2>&1
. ./runEod.sh 6004 $brn_num>> error.txt 2>&1
. ./runEod.sh 6005 $brn_num>> error.txt 2>&1

Now say while running this script job 6003 failed. So at present I have to comment out all the jobs which have run till now and then execute the same. For eg in the above case the script will be as follows:::

# . ./runEod.sh 6000 $brn_num>> error.txt 2>&1
# . ./runEod.sh 6001 $brn_num>> error.txt 2>&1
# . ./runEod.sh 6002 $brn_num>> error.txt 2>&1
# . ./runEod.sh 1010 $brn_num>> error.txt 2>&1
# . ./runEod.sh 1070 $brn_num>> error.txt 2>&1
# . ./runEod.sh 1071 $brn_num>> error.txt 2>&1
. ./runEod.sh 6003 $brn_num>> error.txt 2>&1
. ./runEod.sh 6004 $brn_num>> error.txt 2>&1
. ./runEod.sh 6005 $brn_num>> error.txt 2>&1


Now I don't want this manual intervention of commenting out the previously executed Jobs. The script should run and if it fails it should start from the same point (i.e. 6003 in this case).
# 4  
Old 08-26-2008
then can't you grep the failed jobs from your error.txt??
i mean RC..
# 5  
Old 08-26-2008
Tools Change your thought process, perhaps?

What if you create a file including the list of numbers:
batch_num.lst
6000
6001
6002
1010
...

Then your execution script could do something like the following (in sort of code - as I have only had one cup of coffee this morning!)

Code:
while read bn
  do
  ./runEod.sh $bn $brn_num>> error.txt 2>&1
  if [ $# -eq 0 ]   #ok execution
     then
     sed 's/$bn/#$bn/' batch_num.lst > batch_num.rev
     cp batch_num.rev batch_num.lst
  fi
done < batch_num.lst

You could perhaps do the same kind of logic with the whole command lines as you provided, but still need to do error-checking after each cycle to determine if you should comment-out the successful execution.
# 6  
Old 08-26-2008
its looks fine....
But if you can explain the script a bit more?
I am a bit new to UNIX ...:-)
# 7  
Old 08-26-2008
Depends on shell type you can redefine prompt also, e.g. in ksh
typeset PS4='scriptName [$LINENO]'
set -x
..
someCode
...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with a script to track IPs

Please tell me the script, if any user ping my pc so leave his ip, mac and other identity on my pc. (1 Reply)
Discussion started by: abhihot95
1 Replies

2. UNIX for Advanced & Expert Users

Track the files accessed by a script.

How can i track all the files accessed by script. The script is supposed to bring up my application and this script is just the main script which inturn calls another scripts and executable. I need to know all the the files this main script calls and the files accessed by all the other scripts... (2 Replies)
Discussion started by: chacko193
2 Replies

3. Shell Programming and Scripting

In bash script, how to assign output of a command to a variable while keeping tabs?

Hi, wondering if it's been asked before but didn't find matches from google. Basically I have this line: myvar=$(echo -e "a\tb") Now somehow the '\t' from the echo output gets replaced with white space and then stored in $myvar. It creates a problem for me later to use tab as delimiter to do... (2 Replies)
Discussion started by: birddie
2 Replies

4. Shell Programming and Scripting

Script to monitor a process and track status in a file

i have a scenario where i need a script that monitors a process "Monitor" based on process id... there can be any number of instances of this running... i start this across 4 servers in NFS. Now i need a file which has the process ids of the process that are currently in execution at any... (9 Replies)
Discussion started by: niteesh_!7
9 Replies

5. Shell Programming and Scripting

Keeping last part

Hello, Sorry for the poor tilte but I still don't know how to this. Here is my problem. I have to huge log file. In this log file I can know where is stored all my files. As I have to get a reporting of of files I only need to keep the file name but I don't know how to do it. I hope you... (5 Replies)
Discussion started by: Aswex
5 Replies

6. Shell Programming and Scripting

how to create a logfile to track the below script output

Hi Dudes, Can you please suggest me how to create a logfile to track the below script output ? Thanks #!/bin/ksh # backup the "std" I/P file descriptor exec 5<&0 #echo "Proceed ?" while read config_line; do # backup the I/P file descriptor of "while" block exec 6<&0 # restore the... (2 Replies)
Discussion started by: shirdi
2 Replies

7. Shell Programming and Scripting

How to track and later kill a process in a script

Hello, I am trying to write a script that turns off the screensaver for a certain period of time, then come back on. I have had it up and running for a while, but then I decided to refactor it a bit for my family members that are less computer savvy. I am starting a subshell for the "meat" of... (4 Replies)
Discussion started by: Narnie
4 Replies

8. Shell Programming and Scripting

Mail cleanup from ksh script, keeping 50 most recent msgs

I found some posts describing how to completely clean out a mailbox in Unix/Linux. But I want to keep the 50 most recent messages. Any ideas out there? Thanks! (3 Replies)
Discussion started by: OPTIMUS_prime
3 Replies

9. UNIX for Dummies Questions & Answers

Possible to track FTP user last login? Last and Finger don't track them.

Like the topic says, does anyone know if it is possible to check to see when an FTP only user has logged in? Because the shell is /bin/false and they are only using FTP to access the system doing a "finger" or "last" it says they have never logged in. Is there a way to see when ftp users log in... (1 Reply)
Discussion started by: LordJezo
1 Replies

10. UNIX for Dummies Questions & Answers

house keeping script

Hi, I am not aware whether any one has posted this early or not. I am creating a house keeping script in which I give the user two options: 1. creating a zip file. 2. removing all files given by user. Before taking any action I am asking user to enter full path of file or files to be... (7 Replies)
Discussion started by: Rakesh Bhat
7 Replies
Login or Register to Ask a Question