LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Server shutdown using scripts (https://www.linuxquestions.org/questions/linux-enterprise-47/server-shutdown-using-scripts-579918/)

jeesun 08-26-2007 07:00 AM

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

MS3FGX 08-26-2007 07:34 AM

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.

choogendyk 08-26-2007 07:53 PM

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.

jeesun 08-27-2007 01:20 AM

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?

MS3FGX 08-27-2007 02:05 AM

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?

jeesun 09-03-2007 03:27 AM

yes, i want to log this in local server.


All times are GMT -5. The time now is 08:27 AM.