I created a shell script named df.sh:
#!/bin/sh while true ; do df -hT sleep 30 done &
then I run
./df.sh (I give execute permission).
After running it, I want to terminate the loop but I can't.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
$ pkill -f df.sh
That will send a termination signal to the script and the script will terminate as soon as the current
sleep 30 call has finished.
ps to find the process ID of the script and send a termination signal to it that way:
$ ps $ kill pid
pid is the integer process ID of the script as listed by
First of all if that is you hole script i recommend you to use
& when you calling the script not at the end of the
I recommend you to use
kill to send a terminate signal or
kill -9 to send a kill signal if the process doesn't responding after getting the
pid of the process using
pgrep, you can use
pkill, but, careful it will call all
df.sh processes if you where running more than once, and if you use it with
pkill -f it will kill any process that match