#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2014
    Posts
    2
    Rep Power
    0

    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.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    867
    Rep Power
    391

    Cool


    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
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2014
    Posts
    2
    Rep Power
    0
    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?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2006
    Posts
    2,632
    Rep Power
    1811
    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

IMN logo majestic logo threadwatch logo seochat tools logo