0

How can I make a script to shut down computer while I sleep? I mean, it should shut down the computer when I run the script and start the computer at 6.45 am.

  • 1
    What type of "computer"? – icarus Jan 8 at 6:04
  • Relevant question here. – Sparhawk Jan 8 at 6:08
6

Shutdown is pretty easy:

echo 'sudo /sbin/shutdown now' | at 11pm

Wake-up is much harder - Wake On Lan is the topic to google.

  • 6
    Very good. One simplification is that shutdown takes a time argument. To shutdown at 11pm, it is sufficient to run: sudo /sbin/shutdown 23:00 (23:00 is military time for 11pm). The use of at is unnecessary. – John1024 Jan 8 at 6:22
  • Quite right @John1024. Edited the answer to use 'now' but you can indeed use shutdown with a date and then cancel it later with sudo shutdown -c if necessary. – wef Jan 8 at 6:29
  • 3
    Many firmware setups have an option to set a power on time. Using this is easier than Wake On LAN, which would need another device that is always on. – Johan Myréen Jan 8 at 6:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.