4

I am running some software that takes a while to quit. It must write some large database files.

I have observed that, if I run the software from within xterm, when pressing "quit", the application's name disappears from the panel, but it takes quite a bit longer before xterm returns me to the prompt so I can type any additional commands.

I need to know when the application has successfully and completely quit, so that I do not break the database by quitting Xorg too quickly, but running the program from xterm aways is quite impractical.

  • Is there an alternative means of receiving accurate feedback about when a program has successfully shutdown that does not involve launching it from within xterm?
Village
  • 5,035
  • 15
  • 50
  • 84

1 Answers1

4

Method #1 - using watch

One idea would be to use the watch command to run a 2 second looping command, perhaps something like pgrep ... or ps ...

$ watch "pgrep -l sleep"

Where "sleep" is my stand-in process that I want to watch to see if it's finished. The output would look like this:

Every 2.0s: pgrep -l sleep             Tue Feb  4 22:07:31 2014

24925 sleep

When it's done it would look like this:

Every 2.0s: pgrep -l sleep             Tue Feb  4 22:07:31 2014

Method #2 - using wait

You can also use the same approach that I outlined in this Q&A titled: "Can I somehow add a “&& prog2” to an already running prog1?". The technique would work for you here if you invoked your GUI tool like this:

$ my_database_tool &
[1] 17440

$ wait 17440 && echo "It's done"

...after it's finished...

[1]+  Done                    my_database_tool
It's done
slm
  • 369,824
  • @Village - If this solved your Q can you please mark it as the accepted A so others know you issue's been resolved. Thanks. – slm Feb 13 '14 at 01:40