Need Remote server Reboot timings


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Remote server Reboot timings
# 1  
Old 01-17-2013
Linux Need Remote server Reboot timings

Hi
I need to know the reboot timings of remote servers (all unix/AIX server )with the help of shell script as the list of servers is 400+.

None of the commands uses system name as parameter .What to do ?
I am trying man -b in variety of codes am preparing but all in vain .

Code:
#!/bin/ksh
file="/export/home/ABCDE/readIP.txt" 
while read Line
do
#last reboot | head -1 >reboot data.txt 
echo "line " ":" who -b >rebootData.txt
done < $file

Its not working at all for me

Last edited by Scott; 01-17-2013 at 12:49 AM.. Reason: Please use code tags
# 2  
Old 01-17-2013
hi,

Add the below code in your script

Code:
#!/bin/ksh
file="/export/home/ABCDE/readIP.txt" 
while read Line
do
ssh $line << EOF >output.sri
echo $line  ":" who -b
EOF
done < $file
exit 0

you can find the output in output.sri file

Reason: ssh to every server and exicute the required command and redirect o/p to local machine

Last edited by Scott; 01-17-2013 at 01:05 AM.. Reason: Code tags
# 3  
Old 01-17-2013
ssh needs login credentails ?Is it so ? the above script didnt worked even :-(

---------- Post updated at 10:41 AM ---------- Previous update was at 10:40 AM ----------

would be thankful if some different piece of code will be provided
# 4  
Old 01-17-2013
with out login credentials also you can do ssh ( I am using that right now). we can change the settings in one ssh file for this i didnt remember that exact file name. you can take the help from your admin. In the mean time i will try for other method.
# 5  
Old 01-17-2013
I am saying it because who -b wont take any system name as parameter so seems hard to find reboot time using who -b
# 6  
Old 01-17-2013
I recommend using the same method suggested by srinivas. But before that you have to setup SSH password-less login to each hosts.

Here is a KSH script:
Code:
#!/bin/ksh

while read ip
do
        echo "${ip}\t\c"
        ssh -n ${ip} "who -b | sed -e 's/^[ \t]*\.[ \t]*//'"
done < IP.txt

Here is the output:-
Code:
# ./rb.ksh
135.200.101.79  system boot  Jun 21 01:20
135.31.144.154  system boot  Aug 22 00:51
135.214.229.153 system boot  May 23 01:33

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. Red Hat

Server reboot

Hi, The server got rebooted and below messages can be seen in /var/log/messages Sep 7 10:49:12 minersville kernel: Call Trace: <IRQ> <ffffffff80167420>{__alloc_pages+796} Sep 7 10:49:12 minersville kernel: <ffffffff80182814>{kmem_getpages+106} <ffffffff80183c16>{fallback_alloc+304}... (3 Replies)
Discussion started by: admin_db
3 Replies

3. Shell Programming and Scripting

Sudo connect to a remote server and execute scripts in remote server

Hello Every one!! I am trying to write a shell script which will connect to a remote server and execute scripts which are at a certain path in the remote server. Before this I am using a sudo command to change the user. The place where I am stuck is, I am able to connect to the... (6 Replies)
Discussion started by: masubram
6 Replies

4. Solaris

Validate mountpoints on solaris server after server reboot

Hi, anyone please let us know how to write shell script to find the missing mountpoints after server reboot. i want to take the mountpount information before server reboot, and validate the mountpoints after server reboot if any missing.please let us know the shell script from begining to end as... (24 Replies)
Discussion started by: VenkatReddy786
24 Replies

5. Shell Programming and Scripting

Remote reboot script

I'm a beginner in shell scripting and doing simple scripts for work requirement. #!/bin/bash for blade in `cat machines.txt` do rsh $blade 'reboot' done but when I try it with root password it's throwing error saying permission denied.We're using same root password for all... (3 Replies)
Discussion started by: ratheeshp
3 Replies

6. Programming

SFTP from one remote server to another remote server from desktop

Hi, I have 1. lappy 2. server A 3. server B Now, what i need is to run a command from lappy that will sftp a file from server A to server B. Please guide me to achieve this. -akash (1 Reply)
Discussion started by: akash.mahakode
1 Replies

7. Solaris

Reboot the server through console

Hi All, I want to know the procedure like if server is down, i want to reboot the server through console ($rsc or $sc prompt).Could you please help me out. I would really appreciate your cooperation. thanks for understanding regards krishna (5 Replies)
Discussion started by: murthy76
5 Replies

8. AIX

IP setting changes after server reboot

I've recently changed my gateway setting using SMIT. Everything went fine except that the gateway setting kept reverting back to the old one everytime I reboot the server. I'm on AIX 5.2 running p-Series. Thanks for any info. (3 Replies)
Discussion started by: dereklow
3 Replies

9. UNIX for Advanced & Expert Users

server reboot

hi all, :) for a reboot of sun box for patch installation i would like to know where do the reboot logs apart from /var/adm/messages and patch run messages would be available, i would like to know the sequence of messages logged in the file like requesting the users to log out sending a... (1 Reply)
Discussion started by: matrixmadhan
1 Replies
Login or Register to Ask a Question