LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-05-2011, 01:31 AM   #1
IlbiStarz
LQ Newbie
 
Registered: Jul 2011
Posts: 18

Rep: Reputation: Disabled
Timed Startup


Hey everyone,

So I'm pretty new to Ubuntu. What I want to do is a timed startup.

Right now, I'm using a program called Auto Power on and Shut down on Windows. It let's me set times for the computer to shutdown, power on, hibernate, sleep, and etc.

Is there any program or any script you can write for Ubuntu that lets you do this? I need something like:

Tell computer to turn off at 10am.

*run programs*

Tell computer to (does Linux have hibernate?) something that isn't shutdown but looks like it's shutdown at 5pm. I use hibernate in Windows.

Thanks guys!
 
Old 07-05-2011, 01:50 AM   #2
Metsie
LQ Newbie
 
Registered: Oct 2008
Distribution: Debian testing & SL6
Posts: 7

Rep: Reputation: 3
U can do using crontab:
Code:
sudo crontab -e -u root
add the following line
Code:
0 10 * * * shutdown -h now
About hibernation i don't know!

Last edited by Metsie; 07-05-2011 at 07:43 AM. Reason: Typo
 
Old 07-05-2011, 02:11 AM   #3
IlbiStarz
LQ Newbie
 
Registered: Jul 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Uhh could you explain that for me?

What does each thing mean? I don't know any coding at all so...
 
Old 07-05-2011, 02:16 AM   #4
ganesh24pal@gmail.com
Member
 
Registered: Jun 2010
Location: Mumbai, India
Distribution: CentOS , Fedora, Open Suse
Posts: 193
Blog Entries: 5

Rep: Reputation: 3
Hi,

Crontab is shcedulling a job, from this you can shcedule your sytem to shutdown at what time you required. For more information please find the link .

http://www.linuxnix.com/2009/05/cron...-in-linux.html
 
Old 07-05-2011, 02:23 AM   #5
IlbiStarz
LQ Newbie
 
Registered: Jul 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
So can crontab also schedule boot ups?
 
Old 07-05-2011, 05:00 AM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
No program can run while the computer is off. So, there's no possible script or program that can turn on automatically a computer that's off (or hibernated).

The only thing I can think of is, if you have another computer that's always on on the same LAN, use it to do WoL (wake on LAN). Your computer has to support it though. You will probably find this option in your BIOS, and you might need an aditional wire between your LAN and your motherboard.

About shutting it down, there's no problem. As someone said above, you can do that by scheduling a cron job on that same computer. Read about crontab and cron in general in the internet and try to do it yourself, that way you'll learn. If you have problems then ask here.
 
Old 07-05-2011, 06:46 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,721

Rep: Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914Reputation: 5914
Some BIOSs have a feature where you can wake up the computer at a set time and yes there are utilities for both Windows and linux to wake up a computer from standby. I've never tried them so do not know how well it works. You can use cron to run tasks at a particular time or at startup but it will not boot up the computer.

http://www.osnews.com/story/24111/Wa...for_a_Cron_Job
 
Old 07-05-2011, 01:38 PM   #8
IlbiStarz
LQ Newbie
 
Registered: Jul 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by i92guboj View Post
No program can run while the computer is off. So, there's no possible script or program that can turn on automatically a computer that's off (or hibernated).

The only thing I can think of is, if you have another computer that's always on on the same LAN, use it to do WoL (wake on LAN). Your computer has to support it though. You will probably find this option in your BIOS, and you might need an aditional wire between your LAN and your motherboard.

About shutting it down, there's no problem. As someone said above, you can do that by scheduling a cron job on that same computer. Read about crontab and cron in general in the internet and try to do it yourself, that way you'll learn. If you have problems then ask here.
Well that's what my Windows program does, it wakes the computer up in hibernation.

I'll go try that set time for standby.

---------- Post added 07-05-11 at 11:39 AM ----------

Oh and one more question, is there a way to remotely control the computer using Windows?
 
Old 07-05-2011, 05:31 PM   #9
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by IlbiStarz View Post
Well that's what my Windows program does, it wakes the computer up in hibernation.
Obviously, I don't know very well how hibernation works. Still, you can't use a program to power up a computer that's powered off.

Quote:
Oh and one more question, is there a way to remotely control the computer using Windows?
That depends on what do you want to do. You can login remotely using putty from windows if you have a working ssh server on linux. There are many alternatives.
 
Old 07-05-2011, 05:35 PM   #10
IlbiStarz
LQ Newbie
 
Registered: Jul 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Okay so I've found this thing called rtcwake, it's supposed to wake up your computer after X number of seconds. You can set it to standby, sleep, hibernate.

For some reason it isn't working for me. When I do:

sudo rtcwake -m disk -s 60

It says it'll wake in 60 seconds but it doesn't, my computer stays off. I have to actually boot it up again and then it wakes up from the hibernation. Any help?
 
Old 07-06-2011, 12:37 AM   #11
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
I believe ACPI wakeup is more portable. Just write the wakeup time (seconds since epoch) to /sys/class/rtc/rtc0/wakealarm . Use for example
Code:
sudo sh -c 'date +%s -d "when" > /proc/sys/class/rtc/rtc0/wakealarm'
where when is a human-readable date, e.g. "5pm tomorrow" or "2011-12-31 23:59:59". This assumes you have set your hardware clock to UTC, i.e. in Ubuntu you have UTC=yes in /etc/default/rcS .

ACPI wakeup is screwed by hardware clock updates (hwclock --systohc). I believe this is a hardware issue common to most motherboards. Most distributions do that at shutdown, to keep the hardware clock in sync with the actual clock you use. I believe this is the cause of your problem.

Therefore, I recommend an alternate way (compared to above).

On Ubuntu, replace the script .. end script section in file /etc/init/hwclock-save.conf with something like this:
Code:
script
    . /etc/default/rcS
    [ "$BADYEAR" = "yes" ] && badyear="--badyear" || badyear=""

    wakealarm=""
    [ -f /etc/wakeup ] && wakealarm="$( cat /etc/wakeup )"

    if [ "$UTC" = "yes" ]; then
        tz="--utc"
        wakealarm="$(date +%s -d "$wakealarm")"
    else
        tz="--localtime"
        wakealarm="$(date +%s -u -d "$wakealarm")"
    fi

    hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear

    echo "0" > /sys/class/rtc/rtc0/wakealarm
    echo "$wakealarm" > /sys/class/rtc/rtc0/wakealarm

    exec true
end script
Then, put the wakeup time, as text and not as number of seconds since epoch, in /etc/wakeup instead. You can even use "tomorrow 8am" to always start the machine the next day at 8 am. You can also delete file if you don't want an automatic wakeup to happen.

If you use a custom suspend script -- for example you have a keyboard shortcut that suspends to ram --, you can insert the above (omitting the script, exec true, and end script lines) just before your pm-suspend command. That will then not only also use the /etc/wakeup file (to make sure your computer wakes up then at least), but it will ensure the hardware clock is in sync with your system clock, so it'll wake up at the correct time.

Finally, wake-on-lan works via ACPI too, but it is a separate, independent feature. You can use both WOL and ACPI wakeup at the same time. You can control WOL with ethtool , but remember to enable the source in /proc/acpi/wakeup too. (Use sudo sh -c 'echo "device on" > /proc/acpi/wakeup to enable the device.) The lspci command will show you the devices, so it's easy to compare to the sysfs nodes listed in the /proc/acpi/wakeup file to the long device names shown by lspci.

Hope this helps.
 
Old 07-06-2011, 12:40 AM   #12
IlbiStarz
LQ Newbie
 
Registered: Jul 2011
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Nominal Animal View Post
I believe ACPI wakeup is more portable. Just write the wakeup time (seconds since epoch) to /sys/class/rtc/rtc0/wakealarm . Use for example
Code:
sudo sh -c 'date +%s -d "when" > /proc/sys/class/rtc/rtc0/wakealarm'
where when is a human-readable date, e.g. "5pm tomorrow" or "2011-12-31 23:59:59". This assumes you have set your hardware clock to UTC, i.e. in Ubuntu you have UTC=yes in /etc/default/rcS .

ACPI wakeup is screwed by hardware clock updates (hwclock --systohc). I believe this is a hardware issue common to most motherboards. Most distributions do that at shutdown, to keep the hardware clock in sync with the actual clock you use. I believe this is the cause of your problem.

Therefore, I recommend an alternate way (compared to above).

On Ubuntu, replace the script .. end script section in file /etc/init/hwclock-save.conf with something like this:
Code:
script
    . /etc/default/rcS
    [ "$BADYEAR" = "yes" ] && badyear="--badyear" || badyear=""

    wakealarm=""
    [ -f /etc/wakeup ] && wakealarm="$( cat /etc/wakeup )"

    if [ "$UTC" = "yes" ]; then
        tz="--utc"
        wakealarm="$(date +%s -d "$wakealarm")"
    else
        tz="--localtime"
        wakealarm="$(date +%s -u -d "$wakealarm")"
    fi

    hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear

    echo "0" > /sys/class/rtc/rtc0/wakealarm
    echo "$wakealarm" > /sys/class/rtc/rtc0/wakealarm

    exec true
end script
Then, put the wakeup time, as text and not as number of seconds since epoch, in /etc/wakeup instead. You can even use "tomorrow 8am" to always start the machine the next day at 8 am. You can also delete file if you don't want an automatic wakeup to happen.

If you use a custom suspend script -- for example you have a keyboard shortcut that suspends to ram --, you can insert the above (omitting the script, exec true, and end script lines) just before your pm-suspend command. That will then not only also use the /etc/wakeup file (to make sure your computer wakes up then at least), but it will ensure the hardware clock is in sync with your system clock, so it'll wake up at the correct time.

Finally, wake-on-lan works via ACPI too, but it is a separate, independent feature. You can use both WOL and ACPI wakeup at the same time. You can control WOL with ethtool , but remember to enable the source in /proc/acpi/wakeup too. (Use sudo sh -c 'echo "device on" > /proc/acpi/wakeup to enable the device.) The lspci command will show you the devices, so it's easy to compare to the sysfs nodes listed in the /proc/acpi/wakeup file to the long device names shown by lspci.

Hope this helps.
Now I feel bad because you wrote this much...

I got WoL to work just a few minutes ago XD

Now I'm trying to start some scripts when it boots up...please help me at this thread:

http://www.linuxquestions.org/questi...=1#post4406365

Thanks :P
 
  


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
Connection Timed Out jwthomas Linux - Server 1 05-08-2009 09:34 PM
Samba timed out Lechio Linux - Networking 2 11-17-2008 04:23 PM
Automated Timed Startup ? petelogan SUSE / openSUSE 5 03-01-2008 03:30 AM
sshd timed out mplike Linux - Server 2 01-23-2008 11:09 PM
sendmail - Connection timed out [dsn=4.0.0 stat=Deferred: Connection timed out] ananthak Linux - Software 0 04-24-2007 07:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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