How to execute same script independently?

Hello All,

I have one script for example a1.sh. I want to execute the same a1.sh script inside a1.sh script at the end with different parameter such that the second one will run independently. I don't want the second one to take any input from 1st a1.sh. I tried few things like background/exec etc but no luck.

Thanks
Vikram

Could this help you ?
a1.sh

#!/bin/ksh
if [ "$1" == "RUN" ]
then
        echo "With argument"
        sleep 5
        echo "finished"
        exit 0
fi
echo "Without argument"
a1.sh "RUN" &

Try using nohup

That should help you! :slight_smile:

This is my scenario

Iam running this script as the main script

./app1.sh -e envxxws -b DUMMY -c BPEL configure deploy

and the below one is the one which iam using at the end of this script and it should be run independently

while read file
do
/apps/psr/build_dev/vtanwar/app1.sh  -e "$Env_Name" -b DUMMY  -c BPEL -p $file undeploy 
done < /apps/psr/build_dev/vtanwar/vikram/removable-workflows1.lst
exit
while read file
do
/apps/psr/build_dev/vtanwar/app1.sh  -e "$Env_Name" -b DUMMY  -c BPEL -p $file undeploy 
done < /apps/psr/build_dev/vtanwar/vikram/removable-workflows1.lst
exit

is this the complete script?

If yes, then replace the line /apps/psr/build_dev/vtanwar/app1.sh -e "$Env_Name" -b DUMMY -c BPEL -p $file undeploy

as nohup /apps/psr/build_dev/vtanwar/app1.sh -e "$Env_Name" -b DUMMY -c BPEL -p $file undeploy & This should resolve it :slight_smile:

How about this

nohup sh -c 'while read file; do /apps/psr/build_dev/vtanwar/app1.sh  -e "$Env_Name" -b DUMMY  -c BPEL -p $file undeploy; done < /apps/psr/build_dev/vtanwar/vikram/removable-workflows1.lst' &
exit

@pravin27: why put that while loop in nohup?

PikK45,
Main script will exit after putting while in nohup, no need to wait till file reading finished.
Thanks
Pravin