0

I run a series of silent instances of phantomjs in a script, when the script ends I want to kill them off, all at once. However to make the script look nice and not overload the screens with this message

./runTests.sh: line 74: 26002 Killed phantomjs Lib/loadtester/runTests.js $TEST_COUNT $CLIENT_LIMIT $ACTION $PROFILE $TEST_SERVER $TEST_INCREMENT $DEBUG_MODE > "/tmp/"$TEST_COUNT"_log.txt"

What is the best way to do so, I was currently trying:

(killall -9 phantomjs 2>&1) >/dev/null

And have tried pretty much everything I can think of including all quiet options in killall

Charabon
  • 737
  • 2
  • 11
  • 23

1 Answers1

1

Those messages aren't coming from the killall command. They're coming from the shell when it notices that one of its background child processes has died.

You can prevent this by running the commands in a subshell:

(phantomjs Lib/loadtester/runTests $TEST_COUNT $CLIENT_LIMIT $ACTION $PROFILE $TEST_SERVER $TEST_INCREMENT $DEBUG_MODE > "/tmp/"$TEST_COUNT"_log.txt" &)

The background process is now a child of the subshell, not the original script shell, so the script shell is not notified when it dies. (Actually, since the subshell exits immediately after creating the background process, the background process becomes a child of init.)

Barmar
  • 741,623
  • 53
  • 500
  • 612