Can we create any check-point feature in shell ?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Can we create any check-point feature in shell ?
# 1  
Old 05-28-2019
Can we create any check-point feature in shell ?

I have a script as below and say its failed @ function fs_ck {} then it should exit and next time i execute it it should start from fs_ck {} only

Please advise

Code:
#!/bin/bash

logging {}
fs_ck {}
bkp {}
dply {}

## main function###
echo Sstarting script
echo '####'

logging
fs_ck
bkp
dply

Thanks in advance
abhaydas

Last edited by Scrutinizer; 05-28-2019 at 07:48 AM.. Reason: code tags instead of quote tags
# 2  
Old 05-28-2019
Hi abhayda...
I am curious what are the first four functions are supposed to do except cause errors?
They should look something like this:
Code:
function logging
{
        # There MUST be some code here, using NOP as an example.
        # The colon used as a NOP, DEMONSTRATION placeholder.
        :
}

OR in your case the same would be...
Code:
function logging { :; }

This should help you on your way...

Last edited by wisecracker; 05-28-2019 at 09:03 AM..
# 3  
Old 05-28-2019
HI wisecraker.

Say below is my code for logging and fs_ck function
if script fails at fs_ck function then script should remember this and next time i execute my script it should start from failed point

Code:
function logging  {
        ssh abc@def
        
                if [[ $? -eq 0 ]]; then
                       echo "Successfull"
			    else 
				      echo "Failure"
                        
                fi
        
}

Code:
function fs_ck {
        
        A=`ssh abc@def df -kh . | awk '{print $5}' | tail -1`
        A="${A:0:2}"
        if [ $A -lt 85 ];then
                echo " space issues"
        else
                echo " fine"
        fi
}


Last edited by Scrutinizer; 05-28-2019 at 04:01 PM.. Reason: code tags instead of quote tags
# 4  
Old 05-29-2019
This question has been covered before in these fora; try searching for proposed solutions. This is one of the possible search results.
You could work with - let's call it - "status files". When a function has finished satisfactorily, touch a result file, and skip execution of the function if it exists, like
Code:
bkp ()          { touch ${FUNCNAME[0]}.done; }
logging ()      { touch ${FUNCNAME[0]}.done; }
dply ()         { touch ${FUNCNAME[0]}.done; }
fs_ck ()        { if false; then  touch ${FUNCNAME[0]}.done; else return $?; fi }
for FN in logging fs_ck bkp dply; do [ -f "${FN}.done" ] || { if ! ${FN}; then echo $?; break; fi; };  done

This will execute your functions in the desired order if the result file does not exist. For fs_ck it will fail, won't create the result file, and start over with fs_ck skipping the logging function. Give it a try and report back.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to create a new mount point with 600GB and add 350 GBexisting mount point? IN AIX

How to create a new mount point with 600GB and add 350 GBexisting mount point Best if there step that i can follow or execute before i mount or add diskspace IN AIX Thanks (2 Replies)
Discussion started by: Thilagarajan
2 Replies

2. Shell Programming and Scripting

Check for decimal point and add it at the end if its not there using awk/perl

I have test.dat file with values given below: 20150202,abc,,,,3625.300000,,,,,-5,,,,,,,,,,,,,,,,,,,,,, 20150202,def,,,,32.585,,,,,0,,,,,,,,,,,,,,,,,,,,,, 20150202,xyz,,,,12,,,,,0.004167,,,,,,,,,,,,,,,,,,,,,, My expected output is shown below: ... (1 Reply)
Discussion started by: nvk_vinoth
1 Replies

3. Red Hat

How to create local mount point at startup?

how to create local mount point at startup Filesystem GB blocks Free %Used Iused %Iused Mounted on xxxxxxxx 370.00 180.08 51% 24500 1% /test (5 Replies)
Discussion started by: karthik9358
5 Replies

4. What is on Your Mind?

Speculative Shell Feature Brainstorming

Hi - little introductory post for this thread: The discussion started in the "What's your most useful shell?" poll thread and I think the discussion's gone on long enough that I don't want new posts related to that discussion to go there any more. It's a big discussion and it only gets bigger. ... (26 Replies)
Discussion started by: tetsujin
26 Replies

5. Solaris

archive logs mount point space check script

I have the below shell script which is checking /archlog mount point space on cappire(solaris 10) server. When the space usage is above 80% it should e-mail. When i tested this script it is working as expected. -------------------------------------------------------------------------... (0 Replies)
Discussion started by: dreams5617
0 Replies

6. Shell Programming and Scripting

Shell script for Server Mount Point space check

Does anybody have anything I can use to help me out with this one? (4 Replies)
Discussion started by: lbone007
4 Replies

7. Shell Programming and Scripting

create file as variable for searching point

Hi Friends, I need expert help:), I have bellow script that function for searching string in multiple file, the script is working well. but I thing it still can be optimize since so many repetition in bellow command, where string that I marked BOLD italic is clue for what I am looking for... (2 Replies)
Discussion started by: budi.mulya
2 Replies

8. UNIX for Dummies Questions & Answers

Check if input is an integer or a floating point?

Hiii I actually intent to check the integer or floating point number input by user i.e. 23, 100, 55.25, 12.50 ..etc. However, when someone input strings or alpha character, my program has to show invalid input.!! Is there any Unix shell script syntax can help me to check ? Thanking you (2 Replies)
Discussion started by: krishnampkkm
2 Replies

9. UNIX for Advanced & Expert Users

How to check mount point connectivity in Unix?

I am working on an unix server which has a mount point of windows server in it. I just need to check about the connectivity of this mount point with the windows server. Please let me know what should be done for that. (1 Reply)
Discussion started by: venkidhadha
1 Replies
Login or Register to Ask a Question