I maintain a file server for a research lab, and I need to figure out how to automate shutting down the server while incorporating a delayed reboot. The electricity is being serviced in our building, and we have shut downs scheduled a couple days a week for the next month. The down times vary from an hour to six hours, all in the middle of the night - a time when I wont be around to manually shut down and reboot the computer. Ideally, I'd like to programmatically do this so our files are available to all lab members without increased delays on my part, and because I think it would a very useful piece of code learn. For example, lets say the power will be out this Friday from 2am to 7am, Saturday from 4am to 6am, and again the following Wednesday from 2am to 3am. Is there a way I can programmatically shut my server down 30 minutes before the power goes out, and have it reboot 45 minutes after the power turns back on?
Im using ubuntu desktop 18.04 with samba.
Thanks in advance.