Sponsored Content
Top Forums Shell Programming and Scripting Script execution in sequence manner Post 303002054 by Master_Mind on Wednesday 16th of August 2017 11:28:23 PM
Old 08-17-2017
Thanks Don and all.

Sorry to come with addional requirement in same thread. I need to check for a triggering file say trigger_20170801(which is in YYYYMMDD) to trigger the subsequent scripts. Basically i would require to watch the file in particular directory before the start of the main_script in next day.

To be clear
main_Script.sh is scheduled everday 10:00PM
i need to check for the trigger file till 09:00 PM next day.


if i find the trigger file then proceed with script1.sh and so on
at the successful execution i will make the file as trigger_20170801_success else trigger_20170801_failed

At next day run i will check if success file present for that month i will just come out of the main script stating already completed for this month. If failed file present then exit stating failed for this month.

Using same approach of Don

Code:
echo "Checking for trigger file"
while true;
do
    if [ !-f $trigger_dir/trigg]
    do
   
    sleep 10
	else 

if [ -f $trigger_dir/trigg_success ]
then
echo "Previous run already completed"
exit 0;
fi 
[ -f status ] || date '+0 %c' > status

read job datestamp < status

if [ $job -eq 0 ]
then	if sh -x script1.sh > script1.log
	then	job=$((job + 1))
		date "+$job %c" > status
	else	echo "Failed due to some reason"
	mv $trigger_dir/trigg > $trigger_dir/trigg_failed
		exit 1
	fi
fi

if [ $job -eq 1 ]
then	if sh -x script2.sh > script2.log
	then	job=$((job + 1))
		date "+$job %c" > status
	else	echo "Failed due to some reason"
	mv $trigger_dir/trigg > $trigger_dir/failed
		exit 2
	fi
fi

if sh -x script3.sh > script3.log
then	job=0
	date "+$job %c" > status
	mv $trigger_dir/trigg > $trigger_dir/trigg_success
else	echo "Failed due to some reason"
mv $trigger_dir/trigg > $trigger_dir/trigg_failed
	exit 3
fi
fi
done

I need to validate for that month run trigger file and act. Also check for the trigger file till 09:00 PM next day
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script in boot sequence

Hi , I have some problems with my library when the sytem boot : When HPUX is booting, HPUX and STAPE claim the drive initially. HPUX assigns an instance number. The instance number is tied to the hardware path. Near the end of the boot, the ATDD driver claims the drive from STAPE based... (1 Reply)
Discussion started by: delphine
1 Replies

2. Shell Programming and Scripting

To extract <P> tags in a custom manner from below mentioned input.

Following is input: <P align="justify" ><FONT size="+1" color="#221E1F">the tiny bundles of hairs that protrude from them. Waves in the fluid of the inner ear stimulate the hair cells. Like the rods and cones in the eye, the hair cells convert this physical stimulation into neural im<FONT... (2 Replies)
Discussion started by: parshant_bvcoe
2 Replies

3. UNIX for Advanced & Expert Users

script with a sequence of nohups

Hi, I have written this script below to run a mathematica notebook, and then I want to launch another one when the first one finishes doing what it must. The notebook includes a command which will exit the program math. If I do it like below the two math processes begin at the same time, and... (3 Replies)
Discussion started by: amen_corner
3 Replies

4. Emergency UNIX and Linux Support

Appending the contents of two files in computational manner

Hi, I have two files say file 1 file 2 File1 1 2 4 5 File 2 asdf adf How to get the ouput something like asdf1 adf1 asdf2 adf2 asdf4 adf4 asdf5 (5 Replies)
Discussion started by: ecearund
5 Replies

5. UNIX and Linux Applications

How to log out of the server in such a manner that you are not logged out of PUTTY?

Hi, I am using EXIT command to log out of the server, But this logs me out of the Putty. Is there any way that I can still be present on Putty and just log out of the server. Every time I have to open a new session of PUTTY for a new server (3 Replies)
Discussion started by: himvat
3 Replies

6. Linux

ARM Cortex A9 Core-'1' Execution Sequence

Hi, Iam using OMAP4430 panda board for my project development. It has ARM Cortex A9 MP Core (CORE-'0' & CORE-'1') and iam using linux-2.6.38. Iam just trying to understand the booting sequence for CORE-1. As per my understanding the CORE-1 is triggered from wakeup_secondary(void) in... (1 Reply)
Discussion started by: rajamohan
1 Replies

7. Programming

Help with make this Fortran code more efficient (in HPC manner)

Hi there, I had run into some fortran code to modify. Obviously, it was written without thinking of high performance computing and not parallelized... Now I would like to make the code "on track" and parallel. After a whole afternoon thinking, I still cannot find where to start. Can any one... (3 Replies)
Discussion started by: P_E_M_Lee
3 Replies

8. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

9. Shell Programming and Scripting

How to sort and compare files in more efficient manner?

Hello All, Iam using below method to sort and compare files. First iam doing sorting and changing the same file and then doing comparing and taking the final result to another file. sort -o temp.txt file1 mv temp.txt file1 sort -o temp.txt file2 mv temp.txt file2 sort -o temp.txt... (6 Replies)
Discussion started by: Vikram_Tanwar12
6 Replies
service(8)						      System Manager's Manual							service(8)

NAME
service - run a System V init script SYNOPSIS
service SCRIPT COMMAND [OPTIONS] service --status-all service --help | -h | --version DESCRIPTION
service runs a System V init script in as predictable an environment as possible, removing most environment variables and with the current working directory set to /. The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT. The supported values of COMMAND depend on the invoked script. service passes COMMAND and OPTIONS to the init script unmodified. All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start com- mand. service --status-all runs all init scripts, in alphabetical order, with the status command. EXIT CODES
service calls the init script and returns the status returned by it. FILES
/etc/init.d The directory containing System V init scripts. ENVIRONMENT
LANG, TERM The only environment variables passed to the init scripts. SEE ALSO
/etc/init.d/skeleton, update-rc.d(8), init(8), invoke-rc.d(8). Jan 2006 service(8)
All times are GMT -4. The time now is 08:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy