5
votes
3answers
227 views

Using `kill -s 0 $pid` vs `[[ -e /proc/$pid ]]` to detect if PID is running

One of the idioms often used to check if process is running is to use kill -s 0 $pid. My question is, does it have any upsides over using [[ -e /proc/$pid ]] construct? The script I'm writing is ...
4
votes
3answers
1k views

Terminating a bash shell script running in the background

I often use bash shell scripts to run simple commands for many different files. For example, suppose that I have the following bash shell script, called script.sh, that runs the program/command foo ...
0
votes
2answers
694 views

`ps | grep | kill` aborts my script prematurely [duplicate]

I have a Linux computer that I remotely SSH into using plink on a Windows XP machine. I have the Plink program set to execute commands in a script using automated login: plink -ssh [domain name] -l ...
3
votes
3answers
227 views

Print process ID (PID) of a Matlab instance

To run my Matlab scripts, I've created a shell script to which I give two parameters - the path to the matlab file ($1) and to the log file ($2): nohup time matlab -some_parameters -r "run $1;exit" ...
6
votes
2answers
184 views

Decode Flags for Kill Command

I am new to Shell Scripting. I saw this Command on a Book for Linux shell Scripting $ kill -HUP 1234 >killout.txt 2>killerr.txt I know what the command does, but i am not able to understand ...
2
votes
2answers
492 views

Why can't I kill a timeout called from a Bash script with a keystroke?

[Edit: This looks similar to some other questions asking how to kill all spawned processes – the answers all seem to be to use pkill. So the core of my question may be: Is there a way to propagate ...
3
votes
2answers
1k views

Exit Google Chrome from terminal

Is there a way to cause google-chrome to quit, from the terminal, besides using killall google-chrome? I would like to be able to close it from a script without killing it.
3
votes
3answers
776 views

Killing other user processes

There are certain user environments in which we have to login during certain performance testing and and kill all the process running in that environment. The environment names are like rswrk01, … up ...
4
votes
3answers
1k views

How to kill two or more processes with one kill command?

I am using the following command to kill one java process via shell script: pidof java|xargs kill -9 $1 What if the list of pidof output has more than one elements? How do I kill them both with ...