LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-08-2016, 07:23 AM   #1
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Rep: Reputation: Disabled
shutdown with time delay fails


Shutdown 'now' works but any time delay specified does not shutdown, this is on CentOS 7.

Code:
/sbin/shutdown --poweroff +1
Fails - well it appears to work in that it reports
Shutdown scheduled for ...
but the shutdown never happens.

Code:
/sbin/shutdown --poweroff +0
Also fails.

but
Code:
/sbin/shutdown --poweroff now
works fine.

Any idea why a time delay does seem to work?

Last edited by Nick_C; 05-08-2016 at 08:04 AM.
 
Old 05-08-2016, 07:37 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Did you read the man page for shutdown?

Your posted command is an absolute time vs a delay.
 
Old 05-08-2016, 07:46 AM   #3
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Code:
sleep 60m && shutdown --poweroff now
waits for 1 hour (60 min) and shuts it down
 
Old 05-08-2016, 08:05 AM   #4
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Did you read the man page for shutdown?

Your posted command is an absolute time vs a delay.
Forgot to type +1/+0 in the examples, now corrected.
 
Old 05-08-2016, 08:38 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
I don't think i have tried using a delay with ver 7 and don't have access to a system at the moment. Nothing popped up in a search either.
 
Old 05-08-2016, 09:48 AM   #6
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Teufel View Post
Code:
sleep 60m && shutdown --poweroff now
waits for 1 hour (60 min) and shuts it down
Interesting solution which would work except for...

In this case I am running the shutdown command remotely from a Shutdown script on a Windows server using plink. The one minute delay before it returns causes 'Shutdown Script failed'.
 
Old 05-08-2016, 12:28 PM   #7
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
I'd put these commands into script that located (and runs) at linux side instead of trying to run Linux command at windows side.
 
Old 05-08-2016, 01:53 PM   #8
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Teufel View Post
I'd put these commands into script that located (and runs) at linux side instead of trying to run Linux command at windows side.
Not sure I explained clearly:
Code:
/sbin/shutdown --poweroff +1
Does not work even if run directly on the CentOS 7 machine.
 
Old 05-08-2016, 04:58 PM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
I'm running a basic CentOS 7 installation in virtualbox without a desktop and the shutdown command works as expected i.e.

shutdown --poweroff +1
or
shutdown -h +1

So something is different about your system.
 
Old 05-09-2016, 05:32 AM   #10
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
I'm running a basic CentOS 7 installation in virtualbox without a desktop and the shutdown command works as expected i.e.

shutdown --poweroff +1
or
shutdown -h +1

So something is different about your system.
Thanks for testing that michaelk, as that is the case I have been looking at what is specific to my system.

Looks like a user account issue, issue command as root and works ok but as any other user and the timer fails. Also now noticed when shutdown issued by root the broadcast message is displayed in terminal:
Code:
Broadcast message from root@...:
but when issued by any other user this is not displayed.

Edit:
Don't know which but it is beginning to look like users need to be part of some particular user group to allow shutdown {time} to work, any thoughts which group this might be?

Last edited by Nick_C; 05-09-2016 at 05:41 AM.
 
Old 05-09-2016, 08:49 AM   #11
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Does /sbin/shutdown call some other module to do the time delay? If so this is just as if non-root users do not have permissions to call that delay module.

I should have mentioned that in order to get basic shutdown working with non-root users:
Code:
chmod +s /sbin/shutdown
Is there some other module which needs 'chmod +s' to make this work.
 
Old 05-09-2016, 08:50 AM   #12
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Just to be sure: did you run commands with sudo or su?
To be able to run su/sudo you have to be at wheel group.
 
Old 05-09-2016, 09:04 AM   #13
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Teufel View Post
Just to be sure: did you run commands with sudo or su?
To be able to run su/sudo you have to be at wheel group.
Commands issued from a terminal, either as native user or after su to root. All users are members of the wheel group.

Edit:
For a test just tried but can't run sudo remotely, error is: sudo: sorry, you must have a tty to run sudo

Last edited by Nick_C; 05-09-2016 at 09:06 AM.
 
Old 05-09-2016, 04:27 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Add the -t option i.e.

plink -t user@server_name "your shutdown command"
 
1 members found this post helpful.
Old 05-11-2016, 02:22 PM   #15
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Add the -t option i.e.

plink -t user@server_name "your shutdown command"
Works perfectly, thanks.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how2 disable 30 sec shutdown delay Mint 15 xfce 64bit starkadder Linux Mint 7 12-17-2013 02:26 PM
how to open application and after some time(time delay) automatically it should close santosh vyduyla Linux - Newbie 4 05-27-2013 11:09 PM
delay shutdown if shares are active ?xunil Linux - Server 6 11-15-2008 10:20 PM
shutdown delay in gnome tomwang Linux - Desktop 0 06-25-2007 04:46 AM
'shutdown now' successful, 'shutdown -r now' fails Stomatella Linux - Hardware 4 05-23-2006 10:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:02 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