I have a script that kicks off several processes in the background and stored their pids in a variable as follows:
PID_DUMP_TRAN=$PID_DUMP_TRAN" "$!
so I then have a list of pids
If I echo $PID_DUMP_TRAN I get back a list of pids e.g. 8210 8211 8212
However I then want to kill all these processes at the end of the script. I have tried:
kill $PID_DUMP_TRAN
kill `echo $PID_DUMP_TRAN `
and kill `echo "$PID_DUMP_TRAN"`
I know this is me mis-understanding how to use the variable rather than the kill command and its a fairly basic misunderstanding at that but can anybody point me in the right direction,
I just keep getting an error saying the Arguments must be jobs or PIDS!!!
Whenever you have cut | grep | awk | sed | grep -v | kitchen | sink, you should replace that with awk. It can do it all at once, it's not a glorified cut.
Hi all,
thanks for taking the time to reply. Still can't get this to work so I have included the script and results below.
"## some other stuff goes on here" represents a load of stuff that I have commented out while I get the kill bit working.I have included it to just explain that the script needs to do more than just kick off some jobs and kill them....it needs to kill them when all else is done.
# set the Field Separator to pipe
IFS='|'
set -o xtrace
unset PIDS
unset PID_DUMP_TRAN
CONFIG=/export/home/user/release.config
#DBLIST=/export/home/user/dbdump.config
ISQL_INFILE1=/export/home/user/dump_tran1.sql
ISQL_INFILE2=/export/home/user/dump_tran2.sql
ISQL_INFILE3=/export/home/user/dump_tran3.sql
$SYBASE/$SYBASE_OCS/bin/isql -Uuser -Ppassword -Sserver1 -i$ISQL_INFILE1 >tran_dump1.log &
PID_DUMP_TRAN=$!
$SYBASE/$SYBASE_OCS/bin/isql -Uuser -Ppassword -Sserver1-i$ISQL_INFILE2 >tran_dump2.log &
PID_DUMP_TRAN="$PID_DUMP_TRAN $!"
$SYBASE/$SYBASE_OCS/bin/isql -Uuser -Ppassword -Sserver1 -i$ISQL_INFILE3 >tran_dump3.log &
PID_DUMP_TRAN="$PID_DUMP_TRAN $!"
## some other stuff goes on here
kill `echo "$PID_DUMP_TRAN"`
~