ssh session is not terminating while executing wlst server startup script remotely

We have 100+ Oracle middleware servers that are running on Azure cloud. Most of these servers were not used during weekend. So, guys in infra team thought of saving cost by shutting down MW servers. They asked us  to provide a single script to shutdown all machines and another script to start them. They would invoke these scripts through Ansible and shutdown VMs once all processes on the VM are stopped.

We came up with a wrapper script that will invoke individual component startup scripts. We have two node cluster and wrapper script is placed on node 1. Node 1 will connect to node 2 using ssh and execute individual component scripts on that node. The order is start managed server node manager -> OHS NM ->  Start OHS etc with delay of 30 seconds. But ssh session that starts managed server node manager never terminates. Found this answer on stackoverflow helped.  We added nohup and routed output to /dev/null.
Snippet of the code:
echo “`ssh $userName@$secondNodeIP /bin/bash << EOF
        source ~/scripts/StartStop/$env.env
        nohup  ~/scripts/StartStop/startMNM.sh > /dev/null 2>&1;
        sleep 30s
        nohup  ~/scripts/StartStop/startONM.sh > /dev/null 2>&1;
        sleep 30s
        nohup  ~/scripts/StartStop/startOHS.sh > /dev/null 2>&1;
EOF`” >> $SCRIPT_HOME/logs/startupEnv/startup_$logtime.log
I am not sure this is the best solution. Please share your thoughts in comments section.

Comments

Popular posts from this blog

HOW WE REDUCED SOA OSB PROVISIONING FROM 4 DAYS TO 4 HOURS

NOT ABLE TO START RABBITMQ CLUSTER: CANNOT DECLARE A QUEUE ‘~S’ ON NODE ‘~S’: ~255P

SOA SUITE 12.2.1.4 INSTALLATION: GOT EXCEPTION WHEN AUTO CONFIGURING THE SCHEMA COMPONENT(S) WITH DATA OBTAINED FROM SHADOW TABLE