LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-12-2006, 04:07 PM   #1
Werner
LQ Newbie
 
Registered: Feb 2003
Location: D-Schramberg-Sulgen
Posts: 6

Rep: Reputation: 0
BASH: Is this right?


Hi,

I want that after booting the PC waits
first 3 hours in the background "sleeping"
for following shutdown,
but FULL to use am.

Afterwards it is to switch itself off independently,
but before I must be able to switch it off also at
any time.

Does it go in such a way:

#!/bin/sh
/bin/sleep 3 h && /sbin/shutdown h +m 2

Werner.
 
Old 10-12-2006, 05:12 PM   #2
linmix
Senior Member
 
Registered: Jun 2004
Location: Spain
Distribution: FC5
Posts: 1,993
Blog Entries: 1

Rep: Reputation: 46
often the best way to sheck individual commands is at the cli directly before introducing them into a script.
Quote:
$ /bin/sleep 3 h
/bin/sleep: invalid time interval `h'
Try `/bin/sleep --help' for more information.
There should be no space between the time and the unit: 3h
 
Old 10-12-2006, 07:52 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
And this doesn't work either I think.
/sbin/shutdown h +m 2
It should be "/sbin/shutdown -h $TIMESPEC"

And why waste a sleep? Just set the shutdown for now + 3 hours.
Add to /etc/rc.d/rc.local or equivalent, use "shutdown -c" to stop it:
Code:
TIMESPEC=`date --date='now + 3 hours' +"%H:%M"`
/sbin/shutdown -h $TIMESPEC &
 
Old 10-13-2006, 03:01 AM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Why waste a date?
Code:
/sbin/shutdown -h +180
 
Old 10-13-2006, 01:20 PM   #5
Werner
LQ Newbie
 
Registered: Feb 2003
Location: D-Schramberg-Sulgen
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by spirit receiver
Why waste a date?
Code:
/sbin/shutdown -h +180
O.K. but the warnings make nervous!

Werner.
 
Old 10-13-2006, 08:13 PM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082
So it's better to have the computer shut down with out any warning at all??
 
  


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
Bash Sleep vs crontab and bash serial port nutthick Programming 4 06-01-2006 02:42 AM
(bash) echo "#!/bin/bash" event not found - trying to generate profiles automatically jimieee Programming 9 05-03-2006 10:24 AM
Bash: Print usage statement & exit; otherwise continue using Bash shorthand operators stefanlasiewski Programming 9 02-07-2006 05:20 PM
$LINENO can't be modified in bash 3.0, while it can be in bash 2.05b Darwish Linux - Software 1 11-07-2005 02:57 PM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:37 PM.

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