LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 08-26-2007, 07:00 AM   #1
jeesun
Member
 
Registered: Aug 2007
Location: Australia
Distribution: RedHat Enterprise
Posts: 82

Rep: Reputation: 15
Server shutdown using scripts


I need a shell script in RHEL AS 4.5 for shutdwon the server. The script will run by a normal user. This script will keep track when the server was shutdown.

Please help me regarding this
 
Old 08-26-2007, 07:34 AM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
Unless I am not understanding you correctly, there is no reason to actually have a script for this.

Normal users can be allowed to shut the machine down through the use of sudo, and the record of when the server has been rebooted, shutdown, or had it's run level changed can be viewed with the command "last -x".

You could replicate that functionality with a script if you wanted to...but I am not sure why you would.
 
Old 08-26-2007, 07:53 PM   #3
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
sudo is also a safe way to do this sort of thing, and you can configure exactly what commands each person is allowed. You then also have the sudo log to see who did what in addition to the other system log files telling when a system was shut down.
 
Old 08-27-2007, 01:20 AM   #4
jeesun
Member
 
Registered: Aug 2007
Location: Australia
Distribution: RedHat Enterprise
Posts: 82

Original Poster
Rep: Reputation: 15
thanks for your early reply

My need is that, I want to shutdwon all my linux servers using a batch or shell script from remote end.

Can anyone help regarding this?
 
Old 08-27-2007, 02:05 AM   #5
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
If you want to shutdown a server remotely, you simply need to do something along the lines of:

Code:
ssh user@server sudo poweroff
This will immediately shutdown the remote server, assuming the given user has permission to run the poweroff command through sudo.

This will be logged as a use of sudo on the remote server. Did you want to log this on the local server as well?
 
Old 09-03-2007, 03:27 AM   #6
jeesun
Member
 
Registered: Aug 2007
Location: Australia
Distribution: RedHat Enterprise
Posts: 82

Original Poster
Rep: Reputation: 15
yes, i want to log this in local server.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shutdown linux via scripts from windows westverg General 10 06-28-2007 03:54 AM
KDE shutdown scripts Crobat Linux - General 8 05-23-2007 01:03 AM
shutdown scripts? mushmaster Linux - Software 5 02-15-2005 06:23 PM
Emergency Shutdown scripts? samroberts Linux - Enterprise 3 10-29-2004 04:48 AM
Where do you place shutdown scripts? zer0halo Linux - Newbie 3 08-24-2004 03:43 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 08:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration