Batch script restart timer

septimamus

Estimable
Aug 20, 2014
2
0
4,510
i've been searching for days now, can't find it anywhere. Im looking for a way to reboot the computer using a batch script but with a timer which is set by the user. so if the user wants to reboot the computer in 5 minutes, the script should do that.

(sorry for the poor english.)
 
Do you mean five minutes from now, every five minutes, or five minutes after boot?

If you read the man page for shutdown, you'll see that you need to specify a time as part of the command.

Run 'shutdown 5' for five minutes from now.
 


The 5 minutes is just for example. It's really just what the user wants. So if the user want to reboot in 6 minutes he typs "6" and the command should pick that up and reboot in 6 minutes. or 8 or 20 or two hours. It's just really about the imput of the user.
 
Ah. I don't remember how to enter data into bash; I don't code for others much so tend to just use command line arguments.

A quick Google shows something along the lines of this: (UNTESTED!)
Code:
#!/bin/bash
echo "Enter time to wait (in minutes) before shutting down:"
read minutes
shutdown $minutes