LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 04-15-2006, 07:38 PM   #1
sir_shunt
LQ Newbie
 
Registered: Apr 2005
Posts: 14

Rep: Reputation: 6
Shutdown timer, any ideas?


Well the idea is pretty simple, I want a program or way for my computer to shut down at a preset time (completely turn off). Is there a program capable of this? Or could I write a bash script for this?
Thanks in advance.

Last edited by sir_shunt; 04-16-2006 at 03:31 AM.
 
Old 04-15-2006, 08:17 PM   #2
mazinoz
Member
 
Registered: Mar 2003
Location: Mansfield Queensland Australia
Distribution: Linux Mint - Tara
Posts: 497

Rep: Reputation: 35
Write an executable script and place it in the /etc/cron.d directory. See cron for info.
 
Old 04-16-2006, 02:44 AM   #3
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 85
Or just manually shut it down when you're finished using it for the day - what's the point of leaving the machine powered on if you know you're done using it, and that it will be powered down automatically in a few hours anyway.
 
Old 04-16-2006, 05:34 AM   #4
sir_shunt
LQ Newbie
 
Registered: Apr 2005
Posts: 14

Original Poster
Rep: Reputation: 6
Quote:
Originally Posted by mazinoz
Write an executable script and place it in the /etc/cron.d directory. See cron for info.
I am trying to follow the help files, but I'm not really getting it. What if I want to set it to 1 am for example. would it be:

0 1 * * * /sbin/halt

Btw, J.W. I want to figure this out because eventually I want to use this computer as a gateway, some people here use the internet untill 1 am or so, so it should be on till then, but there's no use to leave it running the whole night.
 
Old 04-16-2006, 09:40 PM   #5
mazinoz
Member
 
Registered: Mar 2003
Location: Mansfield Queensland Australia
Distribution: Linux Mint - Tara
Posts: 497

Rep: Reputation: 35
That may work, you could also try
00 1 * * * root shutdown -h now

You need to ensure it is executable - chmod +x filename (as root)

To test it try setting time for say five minutes from current time and see if it works!

Google may help with your distribution specific quirks _ I use SuSE10
 
Old 04-16-2006, 11:00 PM   #6
Lsatenstein
Member
 
Registered: Jul 2005
Location: Montreal Canada
Distribution: Fedora 31and Tumbleweed) Gnome versions
Posts: 310
Blog Entries: 1

Rep: Reputation: 59
A Crontab entry similar to the following will do it. You need root access..

30 01 * * * /sbin/shutdown -t 120 -hP 2 System shutting down in 2 minutes

Do a man crontab to learn how to create the crontab entry and another "man shutdown" to follow the parameters to the shutdown command.

In my case...
at 1:30 am in the morning, every day of the week, the command shutdown is executed.
It will tell users on the system that in 2 minutes the system will shutdown. It will wait that two minutes time to allow someone to complete his vi edit, or even give other applications enough time to shutdown safely.
 
Old 06-02-2008, 10:46 PM   #7
ckent
Member
 
Registered: Jan 2007
Distribution: Ubuntu
Posts: 59

Rep: Reputation: 15
i've tried to do this by editing my crontab but i run into the issue of shutdown being an admin function. i need to have entered my password in the 15 minutes before it is to shutdown for it to work. i'm using ubuntu Gutsy.

am i doing something wrong? should 00 1 * * * sudo shutdown -P now work?

ck
 
Old 06-02-2008, 11:04 PM   #8
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Does root have a crontab in Ubuntu? If so, put it in root's crontab with sudo crontab -e
 
Old 06-03-2008, 07:49 PM   #9
google01103
Member
 
Registered: May 2006
Distribution: Suse 10.2 x64
Posts: 247

Rep: Reputation: 31
if'n you have the kdelibs installed you can use http://kshutdown.sourceforge.net/ (me being a kde'er) or this http://gshutdown.tuxfamily.org/en/index.php (and there's even Ubuntu deb's http://gshutdown.tuxfamily.org/en/download.php)
 
Old 06-03-2008, 09:57 PM   #10
Lsatenstein
Member
 
Registered: Jul 2005
Location: Montreal Canada
Distribution: Fedora 31and Tumbleweed) Gnome versions
Posts: 310
Blog Entries: 1

Rep: Reputation: 59
What you want to do is standard with crontab. Here is how to proceed

open the terminal shell and issue the sudo command as

sudo su -

It will ask for a password

if you enter id you should see yourself as having the root logon
if not issue another su -
after you have root logon, issue the following command

crontab -e which will invoke vim the enhanced vi editor

enter the following line

30 1 * * * /sbin/shutdown -t 120 -hP 2 System shutting down in 2 minutes

To complete the command hit the escape key to put you into command mode for the editor

and respond with a wq

That will write the above line into the crontab and your system will shutdown at approximately 1:32am every night.

now enter exit several times to leave terminal mode.

Regarding crontab, the first five entries on the line have meanings to allow actions by day of week, by month, etc. do a man crontab to read all about the crontab file
do a man shutdown to read all about the shutdown command
 
Old 06-04-2008, 12:20 AM   #11
ckent
Member
 
Registered: Jan 2007
Distribution: Ubuntu
Posts: 59

Rep: Reputation: 15
i used gshutdown and had the same issues, which is a little weird because what good is it if you can schedule something that you have to be there for anyway. All that aside, "sudo crontab -e" worked like a charm it seems and my NAS now shuts down at 2 every night. Now if i could only get the bios to wake it up automatically...

Thanks a bunch everyone for your help

ck
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Please help on how to save services shutdown or shutdown from the terminal. wambuzz Linux - General 2 03-11-2005 08:38 AM
Linux full shutdown vs. manual shutdown? LQtoto Linux - General 9 01-26-2005 07:21 PM
konsole shutdown possible? or key combo = shutdown possible? Laptop2250 Linux - Newbie 3 11-16-2003 11:44 AM
timer... perdesiz Linux - Software 1 09-18-2003 04:39 AM
QT Timer kusio Linux - Software 1 04-15-2003 06:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

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