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.

2
  • 1
    What type of "computer"? Commented Jan 8, 2019 at 6:04
  • Relevant question here. Commented Jan 8, 2019 at 6:08

1 Answer 1

5

Shutdown is pretty easy:

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

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

3
  • 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. Commented Jan 8, 2019 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. Commented Jan 8, 2019 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. Commented Jan 8, 2019 at 6:57

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.