Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-20-2010, 11:32 AM
|
#1
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Rep:
|
Better to use "at" command instead of time variable in shutdown?
OK, I was reading that if I want to do a one time scheduled command, I should use at, which I've never done, as opposed to cron, which i'm kinda familiar with. But what I want to do is reboot my server at 3am tomorrow and force it to check the file systems with a shutdown -rF.
For this do I even need to use "at" or could I just say shutdown -rF 3:00
Will that also know that I mean 3am tomorrow and not say in 3 minutes from now or 3pm?
I never done this before so I'm kinda paranoid, just looking for some confirmations from the experts so I don't really screw something up. thanks in advance.
|
|
|
|
04-20-2010, 11:51 AM
|
#2
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,899
|
Indeed it is not specified in the man page, but hour is in 24h format. Confirmation from the source code:
Code:
/* Time in hh:mm format. */
if (sscanf(when, "%d:%2d", &hours, &mins) != 2) usage();
if (hours > 23 || mins > 59) usage();
time(&t);
lt = localtime(&t);
wt = (60*hours + mins) - (60*lt->tm_hour + lt->tm_min);
if (wt < 0) wt += 1440;
where you can see that maximum accepted value for hours is 23. And yes, you don't really need to schedule job through at, since shutdown has its own time manager.
Last edited by colucix; 04-20-2010 at 11:52 AM.
|
|
|
|
04-20-2010, 11:53 AM
|
#3
|
|
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,595
|
This is from the shutdown man page:
Quote:
The time argument can have different formats. First, it can be an absolute time in the
format hh:mm, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour
(in two digits). Second, it can be in the format +m, in which m is the number of minutes
to wait. The word now is an alias for +0.
If shutdown is called with a delay, it creates the advisory file /etc/nologin which
causes programs such as login(1) to not allow new user logins. Shutdown removes this file
if it is stopped before it can signal init (i.e. it is cancelled or something goes
wrong). It also removes it before calling init to change the runlevel.
|
As you can see, using shutdown without at may cause problems if users try to login. So, if I were in your place, I would schedule the shutdown/reboot with at.
|
|
|
|
04-20-2010, 11:53 AM
|
#4
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Original Poster
Rep:
|
Thanks for confirming colucix. I didn't see it in the man page either so wanted to ask.
so guess me doing a
shutdown -rF 3:00
will indeed restart and force a disk check on all partitions at 3am tomorrow.
|
|
|
|
04-20-2010, 11:54 AM
|
#5
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Original Poster
Rep:
|
Quote:
Originally Posted by bigrigdriver
This is from the shutdown man page:
As you can see, using shutdown without at may cause problems if users try to login. So, if I were in your place, I would schedule the shutdown/reboot with at.
|
OH, so if I don't use at, I wont be able to SSH back into the server until after it restarts?? that would be BAD, just want to make sure i'm understanding right.
|
|
|
|
04-20-2010, 11:56 AM
|
#6
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Original Poster
Rep:
|
my other problem is I don't know how to use at, could someone help me?
|
|
|
|
04-20-2010, 12:00 PM
|
#7
|
|
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,595
|
It's there in the man page in black and white. So, use the shutdown command without at at your own risk. If it does cause problems with user logins, you can always kill the pending shutdown, which put you back at square one: do I or don't I schedule shutdown with or without at.
I can't think of anything else to say about it.
For examples using at: http://www.kombitz.com/2009/09/17/li...d-at-examples/
www.google.com/linux is your friend. Use it to search for answers to questions you have about GNU/Linux.
Last edited by bigrigdriver; 04-20-2010 at 12:07 PM.
|
|
|
|
04-20-2010, 12:12 PM
|
#8
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,899
|
Well.. the man page also does not mention that /etc/nologin is created 5 minutes before shutdown. Again the source code comes in handy:
Code:
if (wt <= 5 && !didnolog) {
donologin(wt);
didnolog++;
}
where wt is the waiting time in minutes.
|
|
|
|
04-20-2010, 12:19 PM
|
#9
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Original Poster
Rep:
|
OK, so as long as I just do a shutdown -rF 3:00, it will allow new SSH sessions up until 5 minutes before the reboot. That's a pretty nifty little feature they have hidden in there, I never would have know about it.
I'm using RHEL, would it vary between distros or is there something I should check on my server?
Thanks for all the help colucix, I'm learning a lot here.
|
|
|
|
04-20-2010, 12:21 PM
|
#10
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,899
|
Quote:
Originally Posted by rjo98
I'm using RHEL, would it vary between distros or is there something I should check on my server?
|
I think it's the same for all distros, but I cannot tell it for sure. Which package provides the shutdown command on your system?
|
|
|
|
04-20-2010, 12:23 PM
|
#11
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Original Poster
Rep:
|
I'm sorry, but I dont know how to check that to tell you.
|
|
|
|
04-20-2010, 12:38 PM
|
#12
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,899
|
Code:
rpm -qf /sbin/shutdown
the -f option tells which package provides the specified file. In any case I just checked the RHEL sources (actually CentOS) and it is provided by SysVinit (actually I think the shutdown command is provided only by this package, I'd just like to check the version). For sure the behaviour is the same since RHEL4.
|
|
|
|
04-20-2010, 12:41 PM
|
#13
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Original Poster
Rep:
|
Here's what mine said when i issued the command you said.
SysVinit-2.85-4.4
|
|
|
|
04-20-2010, 12:49 PM
|
#14
|
|
Moderator
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.4 OpenSuSE 12.2
Posts: 9,899
|
Ok. I confirm the /etc/nologin appears 5 minutes before shutdown time! 
|
|
|
|
04-20-2010, 12:54 PM
|
#15
|
|
Senior Member
Registered: Jun 2009
Location: US
Distribution: RHEL, CentOS
Posts: 1,140
Original Poster
Rep:
|
Great. Thanks colucix. Now I just have to figure out how if when it goes to shutdown if it has a kernel panic, how to get it to skip over it and continue the reboot and forced disk check. that way the server isn't sitting there doing nothing for hours before i get in.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:42 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|