|
the thpinfo.com blogger archives (2007-2008) Bash: Power off after long-running commandPublished: 2007-12-17T20:39:00.000+01:00
Tags: process, bash, hint, shell, finish, notify
Some weeks ago, I was going to go away from my machine which was running on battery power, but still had a command running (I think it was converting a MythTV recording to XviD) - anyway, I have already started the command and was now looking for a way to say "when this long-running process is finished, please shutdown the machine". Usually, you could do this using "longrunningcommandline && sudo poweroff" or similiar. However, how are you going to do this if the long-running command is already working? I had an idea and tried it straight away - it worked! You basically suspend the process (^Z) and then put it into the foreground again (fg). The "fg" command returns when the command is finished, so doing something like "fg && sudo poweroff" should accomplish the wanted thing. Of course, this can be combined with some nice script like smp to send an SMS when the command has finished. Thomas Perl (thp at this domain); jabber: thp@jabber.org |
|