Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Responsible for reboots. Script help? 2

Status
Not open for further replies.

UsnIT

IS-IT--Management
May 12, 2006
2
US
Hello. I am an IT working for the US Navy (hence the name). I have pretty much no scripting knowledge at all and Im trying to develope a script for reboots.

I'd imagine it would be fairly simple. Try not to laugh at this but if I were to start a script with something like this LOL

#!/bin/csh
telnet (whatever)

how do I get it to enter a user name and password
then su - and another password?

 
man ssh

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Also take a look at the expect command. If your able could you post the Unix version.

When you say a script for reboots do you mean to reboot remote servers?

Another way to do this.

Create a new filesystem called remote & NFS export it to all remote servers you may wish to reboot.

Import the NFS filesystem into all remote servers.

On the remote server create a script that checks every 15 minutes via crontab to see if a file exists on the NFS imported filesystem, if it does run the reboot command.

if [ -f /fullpath/reboot.servername ] ; then
reboot
done

crontab entry

00,15,30,45 * * * * /check.script.sh

Then all you have to do is create reboot.servername in the NFS exported filesystem on your local server to reboot the remote server.




Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Thank you for your reply mrn! To be honest it pretty much went right over my head. I'm not sure I can give away which UNIX version. I dont see anything wrong with it, but someone might.

Im not only rebooting the server computers but also a large handful of client computers.
 
Didn't think you'd be able considering where you work.

Why do you want to reboot?

Will it be a daily / weekly / monthly or ad-hoc thing?

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Create a file system, NFS mount it on all remote clients to reboot, then add a cron entry?

That is the most ridiculous thing I have ever read to reboot remote servers.

Look into expect. Or ssh.
 
Khz

Thanks for your Constructive Criticism. Given that UsnIT is new to *nix and considering he works at a military facility I was trying to give him a solution that doesn't involve possible third party installs like "expect" or "ssh" which may not be cleared for use in a secure environment like his. Given also we don't know his O/S; The method I outlined above is as good a solution as any.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
I'd modify the check script slightly:

Code:
if [ -f /fullpath/reboot.servername ]
then
 [COLOR=red]DT=`date +'%Y%m%d%H%M%S'`
 mv /fullpath/reboot.servername /fullpath/reboot.servername.$DT[/color]
 reboot
[COLOR=red]fi[/color]

Or you'll have a server that reboots on the first 15 minute mark following every startup. Not really desirable. Plus: it's if-then-fi, not if-then-done.


HTH,

p5wizard
 
Opps thanks p5

Too much or not enough medicine last week.....

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
This is the Navy. Security is paramount. NFS more likely than not isn't allowed. And ssh is allowed (probably required). Read the STIGs (thought they have been replaced, but I don't recall what they call them now).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top