Have continuous Ping if SSH session is disconnected.

countryboy

New Member
Credits
60
Hi All,

I am trying to see what the best way to do a continuous ping even if my ssh session is disconnected.
I've tried detaching using the screen command.
I've tried using nohop
I've tried using disown
I've tried using setsid

I do not have root access (since I'm not consider an engineer). So I'm not sure if this is something that a non-root user can do, but figure I ask to see.

Below should be the Server info you need.
Servername:~ $ cat /etc/os-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.6 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.6"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.6 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.6:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.6
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.6"




Servername:~ $ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 7.6 (Maipo)
Release: 7.6
Codename: Maipo




Servername:~ $ hostnamectl
Static hostname: Servername
Icon name: computer-vm
Chassis: vm
Machine ID: <Redacted>
Boot ID: <Redacted>
Virtualization: <Redacted>
Operating System: Red Hat Enterprise Linux Server 7.6 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.6:GA:server
Kernel: Linux 3.10.0-957.5.1.el7.x86_64
Architecture: x86-64
 


Lord Boltar

Active Member
Credits
2,148
In Linux, the ping command line program runs on an endless loop cycle as the default setting.
so you just need to change the website URL you want to ping into an IP address
For example www.redhat.com it is 23.67.82.230

so just run
Code:
ping 23.67.82.230
it will run until you close the terminal
 

countryboy

New Member
Credits
60
So since the SSH Times out after an hour of inactivity, if the ping is still running after I'm booted, I can go back and review the file (since I have it being saved in a .txt file)?

When I tried that, the Ping Log stopped when SSH was ceased due to inactivity.
I'll try it again though and see if I get a different result.
 

Lord Boltar

Active Member
Credits
2,148
Another option is to try PuTTY it is available in Ubuntu repositories I do not know if it is available on Redhat - But I think that it may require sudo to run it.
Code:
dnf install http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/putty-0.70-2.el7.x86_64.rpm
Open terminal
Code:
putty
Click on the Connection Category in the left menu
Check the box for Enable TCP keepalives (SO_KEEPALIVE option)
 

f33dm3bits

Gold Member
Gold Supporter
Credits
12,808
For the ssh time-out problem on your client side you could you can try these settings. So create a file ~/.ssh/config and than add these settings.
Code:
ServerAliveCountMax 60
ServerAliveInterval 2
You can change the numbers if they don't work for you, check man ssh_config for details about these settings.
 

Members online


Top