Automatically disconnecting users from database(s)

Posted by Meave on 01-Jun-2016 02:28

i am sure this is a very basic question but I need to create a batch run that I can schedule that disconnects all user from the databases relating to our ERP system.

All Replies

Posted by George Potemkin on 01-Jun-2016 02:35

Article: How to disconnect all self and remote users from a database?

Posted by Meave on 01-Jun-2016 03:32

Thank you. I did find this KB but I want to run this in a scheduled background batch run and I cannot seem to get it working. There are 8 databases to disconnect. I will play around a bit more with the code

Posted by on 01-Jun-2016 07:48

Hello Meave,

how to do in detail is sometimes different. It will be helpful to know what you are would like to accomplish.

In general there is a simple way:

- Shut down AppServer

- Shud down DB

- Restart DB without AppServer on a _different_ service port and/or with a RO broker as primary broker

(This will empty the cache, that may be negative)

But as I said, this may be the wrong answer, depending on the purpose :)


Posted by Meave on 04-Jun-2016 01:46

Hi Klaus

Thank you for your reply. If I can explain what I am trying to do - I do not want to shutdown the databases. I just want to log everyone out of an application at 7pm every evening. Once they have been logged out the night shift can log straight back in. It has to be a program running in the Windows scheduler.


Posted by George Potemkin on 04-Jun-2016 02:01

> I just want to log everyone out of an application at 7pm every evening.


    FIRST DICTDB._MyConnection NO-LOCK,  
    WHERE LOOKUP(DICTDB._Connect._Connect-Type, "SELF, REMC") GT 0
      AND DICTDB._Connect._Connect-Usr NE DICTDB._MyConnection._MyConn-UserId:

  ASSIGN vCommand = SUBSTITUTE("&1 &2 -C disconnect &3":U,
                       /* &1 */ SEARCH("proshut.bat"),
                       /* &2 */ DICTDB._Filelist._FileList-Name,
                       /* &3 */ DICTDB._Connect._Connect-Usr)
  . /* ASSIGN */

END. /* FOR FIRST _Filelist etc  */

This thread is closed