Command to check if the server is not reachable using ssh
I have list for servers say server1, server2, server3.....server20
I want to test the ssh connectivity of each server, if any one of the server is down then ssh connectivity fails and the script results something like echo "serever is not reachable"
Now I m confused using which command shall I check if the server is not reachable using ssh,
can any one suggest the best solution for this so that I can add it in my code
below are the two command I found and how it works:
command1:
success case:
bash-3.00$ echo $?
0
failure case:
bash-3.00$ echo $?
255
command2:
success case:
bash-3.00$ echo $?
0
failure case:
ssh: server1000: node name or service name not known
bash-3.00$ echo $?
255
Hi there,
I am sorry to ask that kind of beginner thing, but all the code I found online didnt work for me.
All I want to do is: Check via SSH if a File exists on my webserver. The SSH login has to be with username and password.
So I would be very thankful if somebody could write the line.... (8 Replies)
Hello,
i`m tryeing to execute loop on remote server and i have problems with syntax
my command is
ssh root@server "for i in /vz/private/*; do b=`ls -la $i/usr/bin/crontab | awk '{print $1}'`; echo $b; done"
with this command i`m tryeing to get all permissions of file /usr/bin/crontab... (1 Reply)
Hi
The command below does not work as it require to take command in the breakers
But If I do so the variable values get lost
ssh testserver01 'dsmc q b "${ARCHIVE_DIR}*" -sub=yes -querysummary -inactive -fromd="${BACKUP_DATE}"'
Thank you. (3 Replies)
I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd"
i am trying in this manner "
ssh username@servername "cd... (5 Replies)
Hi everyone,
I am trying to figure out a way to ssh to remote server and check if file exists, and if it doesn't I want to leave the script with an exit status of 5.
I have the following that I am attempting to use, but it is not returning anything:
check()
{
ssh ${SOURCE_SERV} "ls -l... (4 Replies)
ssh -q <hostname> /opt/tcs/satish/tst.ksh
ssh -q <anotherserver> /opt/tcs/satish/tst.ksh
tst.ksh has "nohup <command> & "
when i execute below script , its throwing error as
nohup can not be found
ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log &
can someone let me... (5 Replies)