August 12th, 2014, 06:20 AM
-
ssh server date not working
Hi All,
I have 3 servers for 3 function:development,web,and respository purpose.
I am generating a shell script where the script runs in one server and ssh to other 2 servers and fetch their system date and mail a report.
for this i read the 3 server names from dev server and assign it to variable $SERVER, then execute the command ssh $SERVER date 2>/dev/null in a for loop like below:
cat <<!
repo_server
devt_server
web_server
!
)
do
SERVER=$(echo $ENV_SERVER | awk -F',' '{print $2}')
echo "Current system date: $(ssh $SERVER date 2>/dev/null) "
But problem is it prints the current date of the first server in the list "rep_server" for all 3 servers and not their respective ones.I tried the command directly as well and it does nto fetch the date of the remote servers.
August 12th, 2014, 10:09 AM
-
try this:
Code:
SRVARR="repo_server devt_server web_server"
for SERVER in $SRVARR
do
echo -n "$SERVER Current system date: "
ssh $SERVER "date"
done
September 2nd, 2014, 01:37 AM
-
Still it gives the date of the web_server/repo_server which is in MST and not CST time of ETL_server.Not sure why.Could it be the way it is setup in a cluster?
September 2nd, 2014, 07:47 AM
-
What do you get from each server when you run the date command on each of them, manually from the command line?
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc