How to shutdown Linux box with user confirmation?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to shutdown Linux box with user confirmation?
# 1  
Old 04-07-2014
RedHat How to shutdown Linux box with user confirmation?

Hi Guru's
Am looking for linux reboot command which get executed after user confirmation .Can someone please help me with this.SmilieSmilieSmilie
# 2  
Old 04-07-2014
Code:
printf "Are you sure you want to reboot [y/n]"
read RESPONSE
if [ "$RESPONSE" = "Y" ]
then
        /sbin/reboot
else
        echo "response not Y"
fi

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 04-07-2014
Thank you very much Corona.....

---------- Post updated at 01:39 PM ---------- Previous update was at 01:30 PM ----------

Am looking for the inbuilt command option of shutdown or reboot command instead of executing from script.
# 4  
Old 04-07-2014
reboot is not an interactive command.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 04-07-2014
I'm not sure that I understand your question then.

You can take the script that Corona688 has posted and place it in the search path (eg, /usr/bin) and it becomes a 'command' that you can call from the CLI.

If we're on the wrong track please clarify.

Also, I assume that you have root access to do this?

Last edited by hicksd8; 04-07-2014 at 04:32 PM..
# 6  
Old 04-08-2014
Basically was looking for some confirmation option with command reboot / shutdown to avoid accidental reboot of server alike with copy and remove commands
Code:
cp -i /rm -i

but as said by corona688 that reboot is not interactive so will try to put the script on jumphost so that i can start working on it from jumphost itself .
Thanks Corona688 again and hicksd8 too.
# 7  
Old 04-08-2014
When Corona688 says that the 'reboot' command is not interactive I think he means that it doesn't ask for confirmation. If you are root then that command (on most Unix flavors) will reboot the system (instantly) so prone to mistakes.

The 'shutdown' command is the standard way of doing it because you can specify a delay, send a warning to all logged-in users that the system is going down, etc. During the warning period the sequence could be interrupted if it was issued in error.

Another command you should be aware of is 'init' which changes the 'run level'.

Code:
 
 init 0

will close down the system

Code:
init 6

will reboot the system

Code:
init 5

will close down the system and power it off if your PSU supports it.

There are other 'run levels'; see the man page.

Most of the above relates to generic Unix speak. Depending on which flavour you're running, in my experience, 'init <run level>' is more likely to give you an orderly shutdown/reboot than the 'reboot' command.

'init' is the sysadmins short cut and NOT to be used by anyone else.
This User Gave Thanks to hicksd8 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. How to Post in the The UNIX and Linux Forums

Copying , renaming the file from windox box and ftp to Linux box

Hello my dear friends, Two file are auto generated from mon - fri at different directories on same windows box.Every day i have to copy the file, rename it (specific name)and ftp it to linux box specified directory. is it possible to automate this process,If yes this has to be done from windows... (1 Reply)
Discussion started by: umesh yadav
1 Replies

2. Web Development

Pop up confirmation box / perl cgi

Hi, I need to add confirmation pop up msg box before deleting the record from database, I have added following snippets to my code but its not working for me, your help will be much appreciated : print header; print <<EOF; <script type="text/javascript"> function confirmOk() { return... (0 Replies)
Discussion started by: terrykhatri531
0 Replies

3. Red Hat

How to access redhat Linux box graphically from windows box?

Hi I have a linux box and need to access from windows graphically # uname -a Linux pc-l416116 2.6.18-155.el5 #1 SMP Fri Jun 19 17:06:47 EDT 2009 i686 i686 i386 GNU/Linux What components do I need to install on Linux and windows to do that? TIA (6 Replies)
Discussion started by: magnus29
6 Replies

4. UNIX for Dummies Questions & Answers

Mounting Linux box to Linux box

Hi, I've been able to mount my linux box to a windows machine, but I can't seem to mount my linux box to another linux box I have. (I know I could scp, but for other reasons I need to do it this way) Samba is installed. Here is an example where I mount to a Win machine.--> works fine mount... (12 Replies)
Discussion started by: jdilts
12 Replies

5. Red Hat

How to know which user has restarted or shutdown the redhat box?

hi guys! I like to know which user has rebooted or shutdown a redhat box ? the thing is wanted to know the exact user name who has done this action, ofcourse an admin privileged user only can do this. from a list of admin privileged user to find the exact one. i used to go with last... (4 Replies)
Discussion started by: redhatlbug
4 Replies

6. Shell Programming and Scripting

[Solved] Use of until loop for user confirmation

Below is my script that is using to rename the name of file .Here I am using two methods to pass the both arguments wih script name or run the script and give the input one by one.But my issue is I want to rename the name of the file if user select Y(y) then it should rename the file else select... (4 Replies)
Discussion started by: anuragpgtgerman
4 Replies

7. Fedora

The user 'sync' and 'shutdown'

there are 'sync' and 'shutdown' users in my /etc/passwd. ... sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown ... What does these mean? (10 Replies)
Discussion started by: vistastar
10 Replies

8. Shell Programming and Scripting

To provide restricted access to certain user's on linux box

Hi, I need to provide execute access to certain users and not to all users For ex: if ther is a file /home/august/aug.sh. and there are user's like jan,feb,mar,april,May and jan is the owner of that box. I need to provide execute access to feb and mar only. I also know the root pwd for... (3 Replies)
Discussion started by: Ashok_oct22
3 Replies

9. Web Development

Pop up Confirmation Box

Hi, I was writing a simple web application using Perl -CGI. When users try to do some operations, I wanted like a pop-up confirmation box. Is this possible with Perl-CGI? Thanks in advance. Regards, garric (6 Replies)
Discussion started by: garric
6 Replies

10. Shell Programming and Scripting

Script to Reboot a linux box from a windows box

HI All, I need a script to reboot a linux box from a windows box. The script needs to run automatically whenever a sitescope alerts with an error message. Have searched for this in the forums, but could not get something relative. Pls. let me know the various alternatives we have to do... (2 Replies)
Discussion started by: Crazy_murli
2 Replies
Login or Register to Ask a Question