screen command is used to execute the tasks remotely and session can be detached and attached when needed.
$ yum install -y screen
screen [-opts] [cmd [args]]
Create a new session using screen command
Run the required commands in the screen window.
$ date Thu Jun 12 00:13:42 IST 2018
Detaches the screen session using ctrl+ a+ d.
ctrl + a + d
To list all the available screen sessions.
$screen -ls There is a screen on: 12414.pts-0.dhcp35-211 (Detached)
To attach the required screen session.
$ screen -r 12414
|-4||Resolve hostnames to IPv4 addresses.|
|-6||Resolve hostnames to IPv6 addresses.|
|-c file||Read configuration file instead of '.screenrc'.|
|-d (-r)||Detach the elsewhere running screen (and reattach here).|
|-dmS name||Start as daemon: Screen session in detached mode.|
|-h lines||Set the size of the scroll back history buffer.|
|-i||Interrupt output sooner when flow control is on.|
|-l||Login mode on (update /var/run/utmp), -ln = off.|
|-ls [match] or -list||List the screen sockets.|
|-L||Turn on output logging.|
|-q||Quiet startup. Exits with non-zero return code if unsuccessful.|
|-Q||Commands will send the response to the stdout of the querying process.|
|-r [session]||Reattach to a detached screen process.|
|-R||Reattach if possible, otherwise start a new session.|
|-S sockname|| Name this session |
|-t title||Set title. (window's name).|
|-T term||Use term as $TERM for windows, rather than "screen".|
|-U||Screen uses the UTF-8 encoding.|
|-v||Prints screen version.|
|-wipe [match]||Do nothing, just clean up Sockets which are matched.|
|-x||Attach to a not detached screen.|
|-X||Executes command as a screen command in the specified session.|