Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAJsT-000324-0c for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 19:10:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAJsP-0000QM-Fp for pgsql-general@arkaria.postgresql.org; Wed, 10 Oct 2018 19:10:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAJsN-0000PU-GP for pgsql-general@lists.postgresql.org; Wed, 10 Oct 2018 19:10:33 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAJsI-0005fe-Px for pgsql-general@lists.postgresql.org; Wed, 10 Oct 2018 19:10:30 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id EBD8F22169; Wed, 10 Oct 2018 15:10:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 10 Oct 2018 15:10:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=9 ljQ8aVu9vTNsDV3pJEbvMPv/OFRz4TiW3qUzTC9vc8=; b=5V0YcomJzW8g8/Za5 RDtezSqyFuGJPUf73H8CPkFbas5id8oHQhlaS+3wcXY7z2zU5IcdgLgRVD9s984p ZjjqLZbQjKudeaW+mNvcUDiWJBG8iO/b2oOvspT13riAes1kL+LYM+d/pd8fdb9U Z19nzKC8RdOHH1QxdL6/YrqIKSFASSPsTiV+Y6CDQhU5YaP7aIGQDJFkjC1RifWe /tssxTt7xUK89QOcwvyVqL8zLcHogHLJMtFBhPQQcd9p4JmEWJEwqMJLs9/UA2uI /Xj4U3JXhUhHt+q/hSL56t+6Y8Q4ZbHEoWEV6CUQ7MOLxapjVl57ULNagsh9H0Dy ecLPA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=9ljQ8aVu9vTNsDV3pJEbvMPv/OFRz4TiW3qUzTC9v c8=; b=bJtpRRCWuE8+DwN8keTH9oVKRoG/UhRfU6l3V3r4CYGkJL1LWKpIU5rR8 XJZczGorl5Aq/522z3e9MYgmc5bjCx7yUEyE0g02rxuaFQHXhIhZ8/h8HMAuOV3/ 6ELoVcEQVVZ+zXqNzgzUovAvwAfEr9mISZQ0UW9O6oUIN3QAfc6MME1MMk/RqoOk vkMpZpseQ5OhBoTZkMbNj+g2GsaD4lpMup/5jz+MWHjehJbpwjKPONyv7XEbakdk y1EzPHNVN2YgP1MEgMUgARV91I4VZUTtOP9Re9jZhOXEatEbaOj30GWB9zku82Oo qhYBHkp2JmFCERVzw6fQ4qNdNUavA== X-ME-Sender: X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id C1DFBE435E; Wed, 10 Oct 2018 15:10:24 -0400 (EDT) Subject: Re: RHEL 7 (systemd) reboot To: Bryce Pepper , "pgsql-general@lists.postgresql.org" References: <49f8b4546d9948d798d81e1fd32bfb4f@WNEXMBFEP03.KCSCP.CORP> <532b0c39-6b76-658f-fe45-852dd964d7ba@aklaver.com> <5de197dc0e9241c59caad6cb3f69ef25@WNEXMBFEP03.KCSCP.CORP> <5c30d3c8-ddd0-452c-a667-cb1356c10c47@aklaver.com> From: Adrian Klaver Message-ID: <711aa192-9733-8a4c-90a1-46b40876fad9@aklaver.com> Date: Wed, 10 Oct 2018 12:10:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/10/18 7:37 AM, Bryce Pepper wrote: > Sorry, I wasn't clear in the prior posts. > > The stop script is running during reboot. The problem is the database is not reachable when the stop script runs. The ctmdist server shut down is as follows: > Stop control-m application > Stop control-m configuration agent > Stop database Several things: 1) In your OP there was this: Oct 05 14:18:56 kccontrolmt01 network[29310]: Shutting down interface eth0: Device 'eth0' successfully disconnected. Oct 05 14:18:56 kccontrolmt01 network[29310]: [ OK ] Oct 05 14:18:56 kccontrolmt01 stop_ctmlinux_server.sh[29185]: ------------------------ Oct 05 14:18:56 kccontrolmt01 stop_ctmlinux_server.sh[29185]: Shutting down CONTROL-M. So is your Postgres instance running on the same machine as the CTM instance or does the eth0 need to be up to reach the database? 2) In the above there is: "Shutting down CONTROL-M." Yet in script below there is: "Stopping CONTROL-M application" Is this because there are sub-scripts involved or the "Stopping ..." is embedded in the script? 3) I am by no means a shell script expert and I will admit to not fully understanding what control-m_shutdown.sh does. Still here it goes: a) Are there actually two shebangs in one file or are there two files involved? b) What is: # stop database /data00/ctmlinux/ctm_server/scripts/dbversion if [ $? -ne 0 ] ; then echo "SQL Server is already stopped " else if [ -f /data00/ctmlinux/ctm_server/scripts/shutdb ]; then echo "Stopping SQL server for CONTROL-M" /data00/ctmlinux/ctm_server/scripts/shutdb fi actually doing? I ask because from what I can see there are a set of parallel processes initiated and it is possible that the database server is winning. It comes down to what 'if [ $? -ne 0 ]' is testing. > > As you can see the intent is for the database to be shut down after the product. > > But as you noticed from /var/log/message the stop_ctmlinux_server.sh script is running but unable to execute the update query. > > I created the following Service definition and scripts that follow -- note there are 2 datacenters (ctmdist, ctmlinux) that have comparable scripts so I have only included one set: > > [root@kccontrolmt01 ~]# cat ControlM_Shutdown.service > [Unit] > Description=Run mycommand at shutdown > Requires=network.target CTM_Postgre.service > DefaultDependencies=no > Before=shutdown.target reboot.target > > [Service] > Type=oneshot > RemainAfterExit=true > ExecStart=/bin/true > ExecStop=/root/scripts/control-m_shutdown.sh > > [Install] > WantedBy=multi-user.target > > > [root@kccontrolmt01 ~]# cat /root/scripts/control-m_shutdown.sh > #!/bin/sh > # Shutdown any running Control-M services > STATUS=$(/usr/bin/systemctl is-active CTMLinux_Server.service) > if [ ${STATUS} == "active" ]; then > /usr/bin/systemctl stop CTMLinux_Server.service > fi > > STATUS=$(/usr/bin/systemctl is-active CTMDist_Server.service) > if [ ${STATUS} == "active" ]; then > /usr/bin/systemctl stop CTMDist_Server.service > fi > > STATUS=$(/usr/bin/systemctl is-active EnterpriseManager.service) > if [ ${STATUS} == "active" ]; then > /usr/bin/systemctl stop EnterpriseManager.service > fi > exit 0 > > > #!/bin/bash > > # stop CONTROL-M > if [ -f /data00/ctmlinux/ctm_server/scripts/shut_ctm ]; then > echo "Stopping CONTROL-M application" > /data00/ctmlinux/ctm_server/scripts/shut_ctm > fi > > # stop CONTROL-M Configuration Agent > if [ -f /data00/ctmlinux/ctm_server/scripts/shut_ca ]; then > echo "Stopping CONTROL-M Server Configuration Agent" > /data00/ctmlinux/ctm_server/scripts/shut_ca > fi > > # stop database > /data00/ctmlinux/ctm_server/scripts/dbversion > if [ $? -ne 0 ] ; then > echo "SQL Server is already stopped " > else > if [ -f /data00/ctmlinux/ctm_server/scripts/shutdb ]; then > echo "Stopping SQL server for CONTROL-M" > /data00/ctmlinux/ctm_server/scripts/shutdb > fi > fi > > exit 0 > -- Adrian Klaver adrian.klaver@aklaver.com