The Linux Community Forum

Support => General Help & Advice => Topic started by: postcd on April 23, 2014, 11:38:15 am

Title: How to kill some runnin perl script from bash script?
Post by: postcd on April 23, 2014, 11:38:15 am
aim is to kill this script after 120 seconds of running and saving its output to a file. but my command not working and appears not killing the process.

Code: [Select]
#!/bin/sh
set -ex

while read domain;do
output=$(/root/tra*/script.pl $domain & pid=$!
sleep 120
pkill -f $domain)
echo "something"
echo "$output" > $domain_outputfile.txt
cat $domain_outputfile.txt
done < domains.txt

any idea why the command is not killed?
SimplePortal 2.3.3 © 2008-2010, SimplePortal