1845959 Members
1992 Online
110250 Solutions
New Discussion

Re: shutdown script

 
SOLVED
Go to solution
Norman_21
Honored Contributor

shutdown script

I've added the following script to a .profile under a new account that I've created with root permission
shutdown -h -y 0

But when I login using this account to execute the shutdown process, it prompts me with some error msg for a mounting file system. Any suggestions please?
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
12 REPLIES 12
Norman_21
Honored Contributor

Re: shutdown script

Sorry, I forgot to mention the home directory for the shutdown script. It is under /home . Please advise!!
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
Patrick Wallek
Honored Contributor
Solution

Re: shutdown script

Shutdown cannot be run from a mounted file system.

In order for the script to work, you need to add a

cd /

prior to your

shutdown -h -y 0


Your script should work then.
Norman_21
Honored Contributor

Re: shutdown script

hi Patrick,

Thanks man because actually that's what I did but since then I didn't try it. I can only do it once a week.

Will let you know for any further information..
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
Leif Halvarsson_2
Honored Contributor

Re: shutdown script

Hi

Perhaps a better method creating a user for shutting down a system is to configure this in the passwd file
shdwn:uqlOLFsj.DwkQ:0:3::/:/sbin/shutdown -h -y 0
Norman_21
Honored Contributor

Re: shutdown script

hey lief,

That seems interesting, could you please tell me more how waht would be the case with passwd when I login!
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
James R. Ferguson
Acclaimed Contributor

Re: shutdown script

Hi:

Whichever method you choose -- placing the 'shutdown' command in the $HOME/.profile, or more directly, declaring the 'shutdown' command as the user's program to use as a shell in the '/etc/passwd' file, be sure to declare the user as one who is allowed to utilize the command in the first place!

That is, be sure to update '/etc/shutdown.allow' with the user name you desire.

Regards!

...JRF...
Norman_21
Honored Contributor

Re: shutdown script

Hi James,

Thanks man. The shutdown.allow is empty and I'm not sure about it's permission. I would appreciate if let me know.
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
Animesh Chakraborty
Honored Contributor

Re: shutdown script

Hi,
The permission shuld be
-rw-r--r-- 1 bin bin 0 Nov 16 2000 shutdown.allow
Did you take a backup?
Yogeeraj_1
Honored Contributor

Re: shutdown script

hi,

this is a quote from "man 1m shutdown" (has an example will help you proceed):

============================================================
The user is checked for authorization to execute the shutdown command. Only authorized users can execute the shutdown command. See FILES for more information on the /etc/shutdown.allow authorization file.
...
FILES
/etc/shutdown.allow

Authorization file.

The file contains lines that consist of a system host name and the login name of a user who is authorized to reboot or halt the system. A superuser's login name must be included in this file in order to execute shutdown. However, if the file is missing or of zero length, the root user can run the shutdown program to bring the system down.

This file does not affect authorization to bring the system down to single-user state for maintenance purposes; that operation is permitted only when invoked by a superuser.

A comment character, #, at the beginning of a line causes the rest of the line to be ignored (comments cannot span multiple lines without additional comment characters). Blank lines are also ignored.

The wildcard character + can be used in place of a host name or a user name to specify all hosts or all users, respectively (see hosts.equiv(4)).

For example:

# user1 can shut down systemA and systemB
systemA user1
systemB user1
# root can shut down any system
+ root
# Any user can shut down systemC
systemC +

WARNINGS
The user name compared with the entry in the shutdown.allow file is obtained using getlogin() or, if that fails, using getpwuid() (see getlogin(3C) and getpwent(3C)).

The hostname in /etc/shutdown.allow is compared with the hostname obtained using gethostbyname() (see gethostent(3N)).

shutdown must be executed from a directory on the root volume, such as the / directory.

The maximum broadcast message that can be sent is approximately 970 characters.

When executing shutdown on an NFS diskless cluster server and the ???o option is not entered, clients of the server will be rebooted. No clients should be individually rebooted or shutdown while the cluster is being shutdown.
============================================================

hope this helps!
Best regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Norman_21
Honored Contributor

Re: shutdown script

Thanks guys, yo explanation has helped me alot.
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
Norman_21
Honored Contributor

Re: shutdown script

Thanks guys, your explanation has helped me alot.
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003
Norman_21
Honored Contributor

Re: shutdown script

Closed...
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003