Reputation: 1565
I have a couple cli-based scripts that run for some time.
I'd like another script to 'restart' those other scripts.
I've checked SO for answers, but the scenarios were not applicable enough to mine, as I'm trying to end Terminal processes using Terminal.
Process:
Currently none of the terminal windows are named, and from reading the other posts, I can see that it may be helpful to do so.
I can mostly set this up, I just could not find a command that would end all other terminal processes and close them.
Upvotes: 1
Views: 4629
Reputation: 1711
The question headline is quite general, so is my reply
killall bash
or generically
killall processName
eg. killall chrome
Upvotes: 0
Reputation: 5957
There are a couple of ways to do this. Most common is having a pidfile.
This file contains the process ID (pid
) of the job you want to kill
later on. A simple way to create the pidfile is:
$ node server &
$ echo $! > /tmp/node.pidfile
$!
contains the pid of the process that was most recently backgrounded.
Then later on, you kill it like so:
$ kill `cat /tmp/node.pidfile`
You would do similar for the python script.
The other less robust way is to do a killall
for each process and assume you are not running similar node
or python
jobs.
Refer to What is a .pid file and what does it contain? if you're not familiar with this.
Upvotes: 1