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 Answer
Shutdown is pretty easy:
echo 'sudo /sbin/shutdown now' | at 11pm Wake-up is much harder - Wake On Lan is the topic to google.
- 6Very good. One simplification is that
shutdowntakes 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 ofatis unnecessary.John1024– John10242019-01-08 06:22:19 +00:00Commented 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 -cif necessary.wef– wef2019-01-08 06:29:53 +00:00Commented Jan 8, 2019 at 6:29 - 3Many 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– Johan Myréen2019-01-08 06:57:46 +00:00Commented Jan 8, 2019 at 6:57