i have compiled a script as below. Basically this script is intended to call 3 other scripts, which i intend to run simultaneously.
in order to be sure that one instance of the master script runs, i introduced a lock file and then delete it once it is finished, i.e after the 3 scripts are done.
Before removing the lock file I am using the
command in order to see if the process of the 3 scripts still exist, hence still running.
Depending on the result of the kill command i then used
then followed by removal of the lock file.
Is this theory correct or maybe you can suggest another way?
(Note: of course the 3 scripts can run in cron without using a master script, but i am restricted in using a master script, so the idea is to keep it that way)
Change this:
To something like this.
The $? variable cannot be "reused" the way you did - store it in a variable instead. Once the if gets evaluated $?
Plus, the wait command [no argument ] will wait for all children.
If a child fails, wait returns the exit code of the child which, in theory, can be any number (1-255) except 0.
So, you can safely check for a non-zero return.
Also note this important fact: rm removes the directory entry for a file that is open by another process, when that other process exits the physical file is removed from the file system.
A hung child process in a lockfile design can make the script fail and confuse the heck out of you.
This User Gave Thanks to jim mcnamara For This Post:
i replaced the part with your's, it also worked. Did not know that actually the wait command wait for the "sub" processes with the main script. it's also much cleaner.
Hi all,
I have developed a shell script where I am executing datastage jobs.This script will be further placed in enterprise scheduler to trigger it at particulat time.
I have around 300 jobs , I am passing jobnames to script as a paramere. So is it possible I can trigger all jobs from one... (3 Replies)
Dear all,
I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out.
Here is the snippet:-
#!/bin/bash
HSFILE=/root/Test/Components.txt
LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
I've been bitten by using a lock or pid file to prevent multiple instances of a script. A user typed kill -9, and the pid file didn't go away. You can't trap -9. So when he tried to restart, it said "already running", and I got trouble report. Argh.
So here's what we came up with:
# Stop if... (1 Reply)
Hi All,
Just give me an idea on how to do the below logic.
1. I have one master script masterload.sh, the usage of this script is
a. masterload.sh FULL BFLF_LOAD.txt
b. masterload.sh DELTA TDLD_LOAD.txt
c.masterload.sh USER MAS_LOAD.txt
FULL , DELTA ,USER are the varaibles based... (1 Reply)
I need to call 3 different shell scripts from 2 different scripts, one is a perl script and other is Shell script.
In Case -1 :
The perl script is myperlscript.pl
and the name of three shell scripts which need to be called from the perl script are a1.sh, a2.sh and a3.sh. Each shell script... (1 Reply)
Hello gurus,
I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script.
i m looking for something like this
call 3.1;
If 3.1 = "complete" then
call 3.2;
if 3.2 = ''COMPlete" then
call 3.3;
else
exit
The... (1 Reply)
Hi,
I have written a some six scripts to move large files and re-size them. This has been done step by step, taking backup, creating the new files, merging the files, removing the temporary files created.
Since these files are around 500 MB, each step takes somewhere between 1 to 5 mins.
... (1 Reply)
I have created a script to call 2-3 shell scripts to be execute in succession, however, it seems that after the first shell script completes, the entire script exits out.
Example:
1stJob.sh
2ndJob.sh
1st Job - FTP files from Mainframe to Unix using the following commands at the tail of... (1 Reply)
I have a script that calls several other scripts in a specified order:
# Loop over actions in specified order (STOP_ORDER or START_ORDER) and build and evaluate commands
for command in $(eval print '$'${action}_ORDER)
do
printf "`date`\tExecuting ${action}_${command} = `eval print... (1 Reply)
Oracle and Scripting gurus,
I need some help with this script...
I am trying to add the query
SELECT * FROM
ALL_SYNONYMS
WHERE SYNONYM_NAME = 'METADATA'
in the current script....
Read the result set and look for the TABLE_NAME field. If the field is pointing to one table eg.... (18 Replies)