LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 02-03-2008, 07:23 PM   #1
ratcateme
Member
 
Registered: Feb 2008
Distribution: CentOS 5.4
Posts: 59

Rep: Reputation: 15
CentOS 5 remote shutdown


i have 5 CentOS servers and my employer is going green and wants all PC's including the servers turned off at night. I want to know is there a way i can issue a command on one server or a windows PC on the Broadcast address or something to turn my serves off.

Scott.
 
Old 02-03-2008, 09:14 PM   #2
khaos83
Member
 
Registered: Dec 2007
Posts: 97

Rep: Reputation: 15
Not really sure how you want the shutdown to work ...
so i'm throwing everything I can find to you

All about shutdown
http://linux.about.com/od/linux101/l/blnewbie3_1_5.htm

Or you can do a cron job that runs a simple script every interval. The script is empty initially. But when you want it to shutdown, you have to somehow edit it to run the shutdown command. So at the next schedule, the script will shutdown the system. The interesting part is WHERE the script will be. It can be local or in a shared drive.
 
Old 02-03-2008, 09:15 PM   #3
khaos83
Member
 
Registered: Dec 2007
Posts: 97

Rep: Reputation: 15
NOTE, you may have to specify the path of the shutdown command
not really sure.
may not have to ..

Last edited by khaos83; 02-03-2008 at 09:16 PM.
 
Old 02-04-2008, 10:39 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
So long as you can agree a definite time, cron on the linux systems is simplest.
Add it to the root's cron and do use the full pathname. cron confuses a lot of people by having extremely minimal envronment/path settings.
 
Old 02-11-2008, 03:32 PM   #5
slacksite
LQ Newbie
 
Registered: Feb 2008
Posts: 12

Rep: Reputation: 0
Why not do something like:

ssh -l root host.domain.com /sbin/shutdown -h now
 
Old 03-09-2008, 02:55 PM   #6
ncsuapex
Member
 
Registered: Dec 2004
Location: Raleigh, NC
Distribution: CentOS 2.6.18-53.1.4.el5
Posts: 770

Rep: Reputation: 44
Do you want it to also restart the server in the AM automatically? Or will someone manually power the servers up?
 
Old 03-12-2008, 01:36 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
slacksite: generally, remote login as root is discouraged these day, due to the large num of scripts attempting to break in from the net.
I believe more recent version of eg RH/Centos (and others) turn it off in the relevant ssh server config file for a default install.
However, you could use a script like that to login to user that has been given privs via sudo to do the job.
You could automate it using 'expect' or use ssh auth keys, so no passwd is reqd.
 
Old 03-19-2008, 12:30 PM   #8
elimkh
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post
So long as you can agree a definite time, cron on the linux systems is simplest.
Add it to the root's cron and do use the full pathname. cron confuses a lot of people by having extremely minimal envronment/path settings.
chris: hi, I'm pretty new to this forum but was following this thread while looking for some good advise on shutdown using crontab. I edit the crontab table with this:

0 23 * * * /sbin/shutdown -h now

But somehow it does not seems to work. I have the root access to the centos 5.0 server. Any suggestion, please? Thanks.
 
Old 03-20-2008, 01:32 AM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Is that in your crontab or root's crontab ? Normally you have to be root to do that.
 
Old 03-23-2008, 10:52 PM   #10
elimkh
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
Hi Chris,

It's the root crontab. Anyway, I finally got it to work, somehow when you edit your crontab to test, you cannot timed it like a few minute later. I have set crontab for the last couple of evening and it seems to ok now. Thanks!

Cheers mate!
 
  


Reply



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
Remote setup of LAMP server on CentOS 5 satimis Linux - Server 19 01-31-2008 11:42 PM
shutdown issue using centos 5.0 alex.archip Linux - Laptop and Netbook 4 09-09-2007 01:01 AM
[centos] start/shutdown errors pcandpc Linux - Distributions 1 04-27-2007 09:55 AM
Remote Access for CentOS 4 shole Linux - Software 2 04-10-2006 01:16 AM
CentOS 4.2 shutdown on laptop explore Linux - Laptop and Netbook 6 03-16-2006 01:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 09:37 AM.

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