Resume from last failed command


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Resume from last failed command
# 1  
Old 09-28-2014
Resume from last failed command

Dear Experts,

I am creating a shell script (A) which is menu driven and in turn calls another shell scripts (X) depending on the selection. X has a list of commands which runs batch jobs in auto mode.
Content of X
Code:
./sqr.ksh axhri051_sf axhri051_sf.par $1 $2 XHRPPYOV;
./sqr.ksh axbni062 axbni062.par $1 $2 XHRPBYOW;
./sqr.ksh axbni061 axbni061.par $1 $2 XHRPBYOX;
./sqr.ksh axpyi035_sf axpyi035_sf.par $1 $2 XHRPPYA4;

I want to be able to resume directly from A if say a job XHRPBYOW has failed.
The program should "prompt" after it has failed if I want to resume from the last failed job. Upon entering my choice it should resume from like (2 in example) and continue.
Is it possible to do so ? If yes how ?

Thank you for your time.
Your response is much appreciated.

Last edited by Scrutinizer; 09-28-2014 at 03:24 AM.. Reason: code tags
# 2  
Old 09-28-2014
What have you tried so far?
# 3  
Old 09-28-2014
What do these processes do? Do they create files you can use to tell where to continue?
# 4  
Old 09-28-2014
@Corona688
Thank you for the response.
Yes each command like the one below
./sqr.ksh axpyi035_sf axpyi035_sf.par $1 $2 XHRPPYA4;
creates a log file. So if a command aborts, it gets written to that
log file. How can I use that ?
the log file is generally called
XHRPPYA4_datetime.log

@sea
I tried
fg but i assume it is not the right command to be used here.

Do you think I should read the last log file and resume from there ?
Any suggestions how to do that ?

Last edited by Scrutinizer; 09-28-2014 at 03:56 AM.. Reason: code tags
# 5  
Old 09-28-2014
If ./sqr.ksh delivers a correct error code at exit, then you can make X stop at errors if you put
Code:
set -e

# 6  
Old 09-28-2014
What about output files? Is there a file it would create only if it succeeded? I was thinking of using a makefile.
# 7  
Old 09-28-2014
Thank you for the response.
I was reading about makefile and it seems to me it is about compiling a program.
Probably I wasn't clear with my requirements.
I have a master file X.sh which calls A.sh, B.sh or C.sh depending on menu selection.
Now A.sh has commands separated by semicolon.
for example
do 1 ;
do 2;
do 3;
do 4;

Now in-case "do 2" fails (say due to data issue), the program should prompt me if I wish to resume.Depending on my entry. The program should resume from "do 2" and continue and then go back to the main calling program menu X.sh.
Hope I am clear now.
Is it possible for me to know which line the program A.sh got stuck or failed so I may resume from there only ?

Log files are created irrespective of the program's run status. However, these log files says "Its successful" or "Aborted" if it has failed.
I can read that , but how do I tell the program to resume from the last failed command ?

Last edited by rprasad; 09-28-2014 at 03:21 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Command failed for target 'check-recursive' error

Sorry if this is the wrong place for this. I haven't done UNIX Admin in a long time and am trying to update the utilities on a Solaris server so that I can get Apache 2.4.25 installed. I am finding a lot of utilities that are just too far out of date and some versions are no longer supported. So... (0 Replies)
Discussion started by: PJ_Namias
0 Replies

2. Solaris

Script redirect command output failed, why?

Hi, I put a for loop in a script to eject backup tapes from the robot. The command echo' output goes to the log file without problem, but command vmchange's output does not go to the log file although it's working fine. It still displays on the screen. I've tried '2>&1 1>$log', but nothing changed.... (5 Replies)
Discussion started by: aixlover
5 Replies

3. Hardware

Cannot resume from suspend with new motherboardktop, does not resume properly

I would like to get pm-suspend (or any other suspend method) working for a small new desktop computer. It is based on a Zotac GF-8200 ITX motherboard and an AMD Athlon II X@ 240 CPU using ArchLinux x86_64. The pm-suspend script works, apparently putting the machine into suspend correctly... (0 Replies)
Discussion started by: lagagnon
0 Replies

4. Solaris

command 'cc' failed even though gcc is installed

I'm trying to build some python modules on a Solaris 10 machine. It has gcc as /usr/sfw/bin/gcc. # CC=gcc python setup.py build running build running build_py running build_ext cc -c actread.c -o actread.o unable to execute cc: No such file or directory error: command 'cc' failed with exit... (8 Replies)
Discussion started by: aussieos
8 Replies

5. Shell Programming and Scripting

Script exits with $? not 0 randomly, how can I see what command failed?

Hi! I have this situation with 3 shellscripts. One is a "startscript" that simply calls other scripts. This one is scheduled with cron to run at regular intervals. That script runs what I'll refer to as Script 1. Script 1 in turn runs script 2 (import_catalogs_buyer.sh) Sometimes, seemingly... (2 Replies)
Discussion started by: trailsmoke
2 Replies

6. Shell Programming and Scripting

Rerunning a command in a script that failed?

I have a script that occasionally has a command here and there that fails and I would like to set my script up to just re run the command if the exit code is 1. Is there a simple way to do that without if/thens or redirecting to the command again? (5 Replies)
Discussion started by: trey85stang
5 Replies

7. UNIX for Advanced & Expert Users

rm & mv command failed due to too many files.

In our directory there are too many files, & if I try to execute mv *.gz or rm *.l command it fails, providing error string as - 'arg list too long'. This doesnt happen always, is there any way we know, limit on the rm & mv command so we can take care of this failure in future executions ? (9 Replies)
Discussion started by: videsh77
9 Replies

8. UNIX for Dummies Questions & Answers

Problem with Mail command: exec failed. errno=2.

I am trying to send email using the "mail" command. I keep getting an "exec failed. errno=2." message. Here is one the commands I have tried: mail test@mycompany.com < test1.out Any ideas what may be causing this error msg? (1 Reply)
Discussion started by: hawkman2k
1 Replies

9. What is on Your Mind?

Are companies viewing my resume? How do I track my resume visits?

Hi everybody, I am wondering if there is any tool or website out there which can track who is viewing my resume. It is very frustrating when you send your CV or Cover Letter and you receive no feedback from the company, you don't even know if they have checked it out. Thanks for your help (1 Reply)
Discussion started by: gearyipswich
1 Replies

10. Shell Programming and Scripting

Failed to get value from a file using sed command

Hi folks, I have the following file (tnsnames.ora): DB10g = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = buffy)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = DB10g) ) ) EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = ... (2 Replies)
Discussion started by: nir_s
2 Replies
Login or Register to Ask a Question