1847073 Members
4857 Online
110262 Solutions
New Discussion

Re: server shutdown

 
SOLVED
Go to solution
peterchu
Super Advisor

server shutdown

I want to schedule to shutdown the UX server at night time , I want to ask a junior staff to do it , I know the shutdown task need a root user to do it ( but I am not perfer give the root password to the staff ) , could suggest the safety way how can I grant the permission to the staff to shutdown it ( eg. create a userid that only have permission to run the shutdown script ) ? thx
12 REPLIES 12
Cliff Lim Kok Hwee
Regular Advisor

Re: server shutdown

Hi Peter,

y dont u schedule the shutdown in the crontab instead?

No junior staff intervention will be required.

Thanks/cliff
Robert-Jan Goossens
Honored Contributor
Solution

Re: server shutdown

Hi,

Add the user to the /etc/shutdown.allow

or setup a cron enry
00 18 20 05 * /usr/sbin/shutdown -r -y now >>/dev/null 2>&1

Best regards,
Robert-Jan
Nguyen Anh Tien
Honored Contributor

Re: server shutdown

Hi peterchu
why don't you put script in crontab???
be sure that your system do not run database agent at shutdown time (if your system has oracle, DBII... runing , pls shutdown it firts).
1. write shutdown sript
#!/sbin/sh
shutdown -hy 0
SAVE IT TO /downserver.sh
2. add to crontab
#crontab -e
minute hour date month weekday command
00 00 * * * sh /downserver.sh
THAT'S ALL.
HTH
TIENNA
HP is simple
peterchu
Super Advisor

Re: server shutdown

Thx replies,

Yes , I will try to write a script to schedule it , besides that , I also want have a method to shutdown the server when in the unexpected case like power failure or require to urgently shutdown when I am not in the office , so I would ask my colleague to shutdown it for me , is there any method ? thx
Robert-Jan Goossens
Honored Contributor

Re: server shutdown

YES

# vi /etc/shutdown.allow
user_name hostname

Regards,
Robert-Jan
Nguyen Anh Tien
Honored Contributor

Re: server shutdown

To Robert:
I think perterchu should not use
"shutdown -r -y now' because -r option is restart server, he need to shutdown server so I recommend him use -h option
"shutdown -hy 0' or "shutdown -h -y now"
HP is simple
Mobeen_1
Esteemed Contributor

Re: server shutdown

Peter,
I would suggest like many others have done, go ahead and schedule a script for shutdown/startup depending on your requirement. By this if you have some junior staff that need to be notified, this can be done using page/mail on the system. i.e mail/page prior to shutdown and then mail/page when the system is back up

regards
Mobeen
Robert-Jan Goossens
Honored Contributor

Re: server shutdown

Thanks for the correction Tienna :-)

You can also setup sudo to allow a user to run the shutdown command.

Best regards,
Robert-Jan
Pete Randall
Outstanding Contributor

Re: server shutdown

Just remember that you need to put root in your /etc/shutdown.allow file as well. If you don't, root won't be able to run the shutdown command!


Pete

Pete
Gary L. Paveza, Jr.
Trusted Contributor

Re: server shutdown

The way I did this was to setup restricted SAM. This allows me to put a bunch of things in there that run as various users (oracle startup / shutdown, app startup / shutdown / reboots, reset passwords, etc) that my operators can then execute. SAM does the "run as" thing. When I setup restricted SAM, I associated with a group, not a particular user. That way, just the act of creating a user in my operations group gave them the ability to run restricted SAM.
Pravin Salgaonkar
Frequent Advisor

Re: server shutdown

Hi

U Can use the sudo command to assign a user to run the shutdown command

Regards
Pravin S
Mehmood Ansari
Frequent Advisor

Re: server shutdown

Hi

Yes Sudo is best, even you can defined in script Oracle database shutdown/startup.

Ansari