Resume from last failed command


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

This is actually quite a straight forward process, I have used this several times for long shell scripts. Normally I would break the process into a number of component parts, then allocate each to a sub section of a shell. On completion of each section or sub section I write a file in "/tmp" with a numeric value in it, the shell script accepts a number of arguments. With one being to start where the shell finished last time, this is identified by reading the contents of the file in "/tmp".

Regards

Dave
# 9  
Old 09-29-2014
Quote:
Originally Posted by rprasad
Thank you for the response.
I was reading about makefile and it seems to me it is about compiling a program.
You can use makefiles for anything. It is a list of what files are used to create what files, and what programs are used to create them. It can start in the middle, by seeing what files have already been created.

I don't suppose, on the third try, you could actually answer my question?

Is there a file which is created on success but not created on failure? Yes, or no?
# 10  
Old 09-29-2014
Here is an example, written on the assumption your programs create no files.

Code:
# Named Makefile, in the current directory
file4:file3
        ./sqr.ksh axpyi035_sf axpyi035_sf.par $1 $2 XHRPPYA4;
        touch file4
file3:file2
        ./sqr.ksh axbni061 axbni061.par $1 $2 XHRPBYOX;
        touch file3
file2:file1
        ./sqr.ksh axbni062 axbni062.par $1 $2 XHRPBYOW;
        touch file2
file1:
        # Code to run program1 here
        # Leave the 'touch', Make needs it to track
        ./sqr.ksh axhri051_sf axhri051_sf.par $1 $2 XHRPPYOV;
        touch file1

clean:
        rm -f file1 file2 file3 file4

When you run make, it will attempt to create file1 through file5 in that order, by running the commands you tell it to. If there is an error, it will detect the nonzero return code and stop in the middle. Next time you run it, it will remember where it left off by what file1...file5 files have and haven't been created.

Run 'make clean' to remove the files and start over from the beginning.

NOte that the eight leading spaces are actually tabs and must be tabs for make to work.
# 11  
Old 09-29-2014
Hi,

Here is the start screen from a script that I run to configure Solaris Zones, is this the type of thing that you are looking for?

Code:
# -------------------------------------------------------------------------------------------------------
# This programme checks the installation, configuration and the observance of the standards 
# and Security Policy for Solaris 10 systems.
# (c) NOOBAB.COM : xxxxxxxxxxxxx.xxxxxxx.xx.xx :  Mon, Sep 29, 2014 16:39:32
# -------------------------------------------------------------------------------------------------------
#
 please wait 
# -------------------------------------------------------------------------------------------------------
# At first the program checks the last Step in the last run. 
# If the programm was crashed or you have stopped the script with <Crtl-C> 
# You have the chance to start the programm from the last step.
# -------------------------------------------------------------------------------------------------------

   - Would you like to start this script from ... 
       - the last Section where the script is broken ?      Type [ 'L' ]
       - the Beginning of this Script ?                     Type [ 'B' ]
       - from a specific Section No ?                       Type [ 'S' ]

# -------------------------------------------------------------------------------------------------------
   Your input please:                                               S



   SECTION:  1 - Check NFS Configuration
   SECTION:  2 - Check '/etc/hosts' if global informations included
   SECTION:  3 - Check '/etc/profile' and '/etc/nsswitch.conf'
   SECTION:  4 - Check zfs-filesystems if exists 
   SECTION:  5 - Check if 'UX-User' included in '/etc/passwd' and '/etc/group'
   SECTION:  6 - Check whether directorys are existing
   SECTION:  7 - Check and Run 'rsync' to copy default configuration on taget system
   SECTION:  8 - Check group permission of file '/var/adm/messages' must be: 'bmcadm'
   SECTION:  9 - Check 'Quest-SSH' configuration
   SECTION: 10 - Check 'VAS Tool' configuration
   SECTION: 11 - Check join local server '' to the active directory
   SECTION: 12 - Check if the services 'vasd', vasgpd' and 'quest-ssh' are started
   SECTION: 13 - Check Hardening netservices
   SECTION: 14 - Check NTP Configuration and SMF-Service
   SECTION: 15 - Check File 'dsm.sys' for TSM-Client
   SECTION: 16 - Check Configuration defaults
   SECTION: 17 - Check default security configuration
   SECTION: 18 - Check 'rsa' and 'dsa' keys for ssh
   SECTION: 19 - Check 'EMC PowerPath Registration' (only on global zones)
   SECTION: 20 - Check 'SYMCLI EMC Solutions Enabler' installation (only on global zones)'
   SECTION: 21 - Check installation of 'TDPO' software
   SECTION: 22 - Check 'Smart' relay host to 'DSmailgw2.zzz.com
   SECTION: 23 - Check 'Patrol' installation and configuration for server '' XML-File
   SECTION: 24 - Check 'UC4' configuration
   SECTION: 25 - Check if the Services for 'vasd', vasgpd' and 'quest-ssh' are started
   SECTION: 26 - Check 'syslog' configuration
   SECTION: 27 - Check script File '/etc/motd'
   SECTION: 28 - Check 'os-als-role2server' if Server '' included'

   Please enter a Section No. 1 - 28 :

Some of the sections have more depth as well, in this script there are around 6000 lines. Is this the type of thing that you are looking for?

Regards

Dave
# 12  
Old 09-30-2014
@Dave
Yes, this is exactly what I am looking for.

@Coronoa...thank you again.
The log file is created no matter what , whether the command is successful or not.
How do I tell the program to resume from say "file 5" ?
# 13  
Old 09-30-2014
As an idea you could try:
Code:
tail logfile

Which will show the last few entries within mentioned logfile, and parse that given output, and then act accordingly.

hth
# 14  
Old 09-30-2014
Quote:
Originally Posted by rprasad
@Coronoa...thank you again.
The log file is created no matter what , whether the command is successful or not.
How do I tell the program to resume from say "file 5" ?
That's what the 'touch' is for in the makefile, to create flag files on success to remember where it left off.
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