Linux – how to execute command after current running command in bash


I'm downloading file with wget, and I want to turn off my computer after downloading will be finished, but I need to go somewhere now 🙂 Is it possible to execute command in bash exacly when process will be finished?

I know that this works:

wget; shutdown now

But what if I type only:


Best Answer

You can do something like this:

  1. stop execution of wget with ctrl-z (it's not stopped, it's suspended)
  2. put it into background (bg)
  3. run: wait; shutdown -h now

wait will wait for all programs ran in background from current shell - i.e. this wget.

After wait will finish - shutdown will go on.