Suppressing the terminated message from pkill & killall commands in a bash script
Hi all,
I've been pulling my hair out with this problem for 3 days now without success any help would be massively appreciated.
Basically the script is used to shutdown a rails server so a new IP address can be assigned, the shutdown part is taken care of in function_one using the "pkill master" command. Once the server has been shutdown function_two is supposed to run and restart the server.
The problem is the when "pkill master" is run and the processes are killed the script is broken by the terminated message and function two never gets called. I understand that the terminated message is not coming from STDOUT or STDERR and that it is being generated by the shell's job control mechanism so I cant redirect to /dev/null or use 2>/dev/null to redirect the message.
I'm at my wits end I can not find a way to "pkill master" or "killall -q -r master" without generating the terminated message. Thanks in advance.
This work
#!/usr/bin/sh
COMM=${1}
shift
UNIX95=1 ps -C ${COMM} -o pid='' | while read P
do
kill -15 ${P}
done
This don't work
#!/usr/bin/sh
COMM=${1}
shift
UNIX95=1 ps -C ${COMM} -o pid='' | while read P
do
kill -"$@" ${P}
done (7 Replies)
I need to capture lengthy screen puts and direct to .txt.
Script command is started on Wed Aug 22 13:27:36 EDT 2012.
# qcp
sh: qcp: not found.
An issue I have is that script command doesn't take non-AIX commands.
I need to run application-specific commands and capture the output in... (2 Replies)
I'd like to create an alias that displays my string but leaves my cursor at the end.
Not seeing any examples of this.
One indirect way might be to preload or stuff the history buffer, so I just hit up arrow. (2 Replies)
I have a script which checks for *.txt files in a particular directory and if no files were found then it goes into sleep for 10 secs and looks back for files again and if any files were found then the script does some processing with the files found, which is my requirement too.
FILE_EXISTS=`ls... (5 Replies)
I need to suppress the error message for commands. I have given the command like below
lsb_release -dr 2>/dev/null
But it is not working.
Am testing with Red Hat Linux release 9. Guide me.
Thanks in advance (2 Replies)
I am testing some file routines against potential "nasty name" Unix files, such as those with a CR, LF, in the middle or NULL terminated, utf multi-byte character. So, under Bash, I want some way of:
mv "name" "name\0"
with the \0 a real NULL.
Against all my efforts, I have not been... (2 Replies)
Hi,
I have a BASH shell script that batch processes data. I often start this script before I leave to go home for the day, and leave it processing over night. It has come to my attention that it would be very useful for me to add the capability of making the script notify me about certain things... (2 Replies)
hi
I'm new here so my question maybe be retarded or out of place:
Is there a way to suppress the "No such file or directory" error message when using the "ls" command ?
thanks (5 Replies)
I am doing some system tuning and figuring out how to write a script that will kill multiple processes or all processes with the same owner. Can someone help me out? Thanks (5 Replies)
Does anyone know how I can supress the "Killed" message that's produced when I kill a process? I've got a script that performs a "tail -f" on a database error log and pipes the output into an awk script which looks for certain error messages and forwards any that qualify to my pager. The problem... (2 Replies)