restart parameter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting restart parameter
# 1  
Old 02-21-2011
restart parameter

I have a shell script with 4 separate functions taking place, one after the other.
Is there a way to introduce a parameter so that if the job fails, then I can restart it at a specific point in the script ?
Ideally, the default will be null (or 1), so that it will not normally be set, and the script will start at the beginning.
But if the script were to fail between stages 2 and 3, say, then the script could be rerun, with the parameter set to 2.
Many thanks
# 2  
Old 02-21-2011
Your scripts should managed flags, so when step 1 is complete, you create a flag
Code:
FLAG="/tmp/flagstep2"
touch $FLAG

On the other hand, at the beginning of your script, you should check for the existence of that flag:
Code:
[[ -f "$FLAG" ]] && step2 || step 1
step3 && rm "$FLAG"

if found : restart from step 2 else, start from the beginning (step 1).

This flag will be removed after step 3 has completed successfully.
# 3  
Old 02-22-2011
restart parameter

Thanks ctsgmb
For your code to work, should I declare headings in my script,
like step1, step2, step3, step4 ?
If so, do I need special characters around them to make them headings ?
And should there be similar tests after each step and at the begining of the script to send control to step3 or step4 : in your reply only step2 is being catered for ?
Many thanks for your help.
# 4  
Old 02-22-2011
Of course you need to code the step1 step2 ... and so one.

Please post what you did try so far
# 5  
Old 03-02-2011
Restart Parameter

Hi ctsgnb
Thanks for your contributions, but I now no longer need to string all the scripts together. It will be handy for me to know how to do this in future, though, and so I will do some more testing later on to sus this one out.
Thanks again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call Script with Parameter (that has another parameter)

Hi. How do I achieve this sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this sh /EDWH-DMT02/script/MISC/exec_sql.sh... (7 Replies)
Discussion started by: aimy
7 Replies

2. Shell Programming and Scripting

Resolving a parameter which is passed as parameter

Hi, I have the following files. ->cat scr.sh export TMP_DIR=/home/user/folder1 export TMP_DIR_2=/home/user/folder2 while read line do cat "$line" done<file_list.dat ------------------------ -> cat file_list.dat $TMP_DIR/file1.txt $TMP_DIR_2/file2.txt --------------------------- -> cat... (6 Replies)
Discussion started by: barath
6 Replies

3. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

4. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

5. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Red Hat

Restart SMSPI

I know this sounds silly but im not sure where my smspi is located. I want to restart the services but im not sure where to look at. I dont have init.d in my /sbin : # cd /sbin # cd init.d -bash: cd: init.d: No such file or directory Its running at this time: -bash-3.00$ ps -ef... (2 Replies)
Discussion started by: hedkandi
2 Replies

7. Solaris

sysedge restart

on a solaris box, if somebody restarts sysedge, which log file (path) can we look at to determine if sysedge was restarted or not? Thanks, (1 Reply)
Discussion started by: Pouchie1
1 Replies

8. UNIX for Dummies Questions & Answers

Restart a Daemon

Dear expert, How do i restart a daemon ? I know to use the kill <PID> command to shut down the daemon. But after terminate the daemon, how to restart it back ? :confused: Please advice, many thanks in advance !!! :) (2 Replies)
Discussion started by: kseng2002
2 Replies

9. Shell Programming and Scripting

Restart a Service!!

Hello, I am trying to write a script which will monitor few processes(winbind) for cpu utilization, If the process consumes more than say 99% cpu for 3 minutes, I want to run a script to restart the service which forks the process. ---------- Post updated at 11:21 AM ---------- Previous update... (5 Replies)
Discussion started by: linuxaddict7
5 Replies

10. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies
Login or Register to Ask a Question