I want to run bash in a specific time(With at command ) for 3 minutes after that, I want to shut down the machine
This is my bash code (send.sh) :
$ x=10
echo The value of variable x = $x
and this is my
atcommand :
at 2:30 PM tomorrow
what should I write in send.sh for running for 3 minutes and then shutting down the machine
I don't understand why you want to execute the "waiting" part inside of your script: you can simply do the following, using
at(pseudo-code):The problem is that, if you put it somewhere in "send.sh", the following might happen:
send.sh content:
<do_something>might take some time, and the shut down will be launched later than the expected three minutes.<do_something>might go wrong, causing your script to abort and your machine won't be shut down at all.Hence my proposal to create two separate
atentries.Edit, after comment from Socowi:
Apparently, one can add an
at-clause after a command, as follows:This might be the solution you're looking for.