I started a process in the background using:
erl -s system start -detached
I need to kill the process. Is there a way to kill all processes that are running in the background?
I tried:
init:reboot()
if you want to kill all running erlang processes on your system, probably run this as super user if possible. In the bash shell:
for i in `ps -ef | grep erl | awk '{print $2}'`; do echo $i; kill -9 $i; done
One way to achieve this is to start another erlang console, attach from it to first one and do all necessary things to terminate it properly.
You need to know name of the target node. From your example node is started without any name, you can give it by adding flag -name -sname like this: erl -sname node_1 -s system start -detached
Start another node with different name: erl -sname node_2
Press ^G (control G) on the terminal with node_2
Press r and type name of the first node: node_1#localhost (or whatever name it have)
Press c
Eshell V5.10.1 (abort with ^G)
(node_2#localhost)1>
User switch command
--> r 'node_1#localhost'
--> c
Eshell V5.10.1 (abort with ^G)
(node_1#localhost)1>
You shell see new prompt with name of the first node. Now all your commands will be executed on the first node. To terminate first node you could type erlang:halt().
Related
I'm using TestCafe to test an app I'm working on. Today, when I went to run a TC test, I got the following message:
Error: listen EADDRINUSE: address already in use :::57664
I can usually handle these pretty easily: I issue the command:
lsof -i -P | grep -i "listen"
or
lsof -i tcp:57664
and then kill the offending task that is identified.
However, in this case, that port number isn't listed so I don't know which task to kill. also,
ps aux | grep -i "TestCafe"
doesn't show anything helpful.
Any suggestions on how to identify the hung task and kill it?
I'm running multiple 'shred' commands on multiple hard drives in a workstation. The 'shred' commands are all run in the background in order to run the commands concurrently. The output of each 'shred' is redirected to a text file, and I also have the output directed to the terminal as well. I'm using tail to monitor the log file for errors, and halt the script if any are encountered. If there are no errors, the script should simply continue on to conclusion. When I test it by forcing a drive failure (disconnecting a drive), it detects the I/O errors and the script halts as expected. The problem I'm having is that when there are NO errors, I cannot get 'tail' to terminate once the 'shred' commands have completed, and the script just hangs at that point. Since I put the 'tail' command in the 'while' loop below, I would have thought that 'tail' would continue to run as long as the 'shred' processes were running, but would then halt after the 'shred' processes stopped, thus ending the 'while' loop. But that hasn't been the case. The script still hangs even after the 'shred' processes have ended. If I go to another terminal window while the script is "hangiing," and kill the 'tail' process, the script continues as normal. Any ideas how to get the 'tail' process to end when the 'shred' processes are gone?
My code:
shred -n 3 -vz /dev/sda 2>&1 | tee -a logfile &
shred -n 3 -vz /dev/sdb 2>&1 | tee -a logfile &
shred -n 3 -vz /dev/sdc 2>&1 | tee -a logfile &
pids=$(pgrep shred)
while kill -0 $pids 2> /dev/null; do
tail -qn0 -f logfile | \
read LINE
echo "$LINE" | grep -q "error"
if [ $? = 0 ]; then
killall shred > /dev/null 2>&1
echo "Error encountered. Halting."
exit
fi
done
wait $pids
There is other code after the 'wait' that does other stuff, but this is where the script is hanging
Not directly related to the question, but you can use Daggy - Data Aggregation Utility
In this case, all subprocesses will be end with main daggy process.
Once I've started tensorboard server with the command
tensorboard --logdir=path/to/logdir
is there a command that explicitly close it or can I just kill it without any harm?
Thanks
In my case, CTRL+C doesn't work. The following works for me:
CTRL+Z halts the on-going TensorBoard process.
Check the id of this halted process by typing in the terminal
jobs -l
kill this process, otherwise you can't restart TensorBoard with the default port 6006 (of course, you can change the port with --port=xxxx)
kill -9 #PROCESS_ID
You can kill it without any harm! TensorBoard simply reads your log files and generates visualizations based on them in memory, so you don't need to worry about file corruption, etc.
This command will find the tensorbroad process and terminate it:
kill $(ps -e | grep 'tensorboard' | awk '{print $1}')
I solved this problem by this way - (actually in my ssh, sometimes CTRL+C don't work properly. Then I use this)
Get the running tensorboard process details
ps -ef|grep tensorboard
Sample Output: uzzal_x+ 4585 4413 0 02:46 pts/4 00:00:01 bin/python /bin/tensorboard --logdir=runs/
Kill the process using pid (process id)
kill -9 <pid>
first number 4585 is my current pid for tensorflow
There is a shortcut that is more drastic than CTRL+C:
Try CTRL+\
You can write this:
ps -ef | grep port_number
Get the port number of the tensorboard, then use:
kill -9 PortNumber
On windows, use: taskkill /F /PID <pid> where <pid> is the process ID.
I want to make a shell where the child process runs linux commands(with the help of execvp) such as "ls" etc.The problem is that i also want it to support pipe commands such as "ls /tmp | wc -l" .Τhe program i have for now works for commands like "ls" or "ls -l /tmp" :
I have fooinit.rt process launched at boot (/etc/init.d/boot.local)
Here is boot.local file
...
/bin/fooinit.rt &
...
I create an order list at job in order to kill fooinit.rt. that is Triggered in C code
and I wrote a stop script (in)which kill -9 pidof fooinit.rt is written
Here is stop script
#!/bin/sh
proc_file="/tmp/gdg_list$$"
ps -ef | grep $USER > $proc_file
echo "Stop script is invoked!!"
suff=".rt"
pid=`fgrep "$suff" $proc_file | awk '{print $2}'`
echo "pid is '$pid'"
rm $proc_file
When at job timer expires 'kill -9 pid'( of fooinit.rt) command can not terminate fooinit.rt process!!
I checked pid number printed and the sentence "Stop script is invoked!!" is Ok !
Here is "at" job command in C code (I verified that the stop scriptis is called after 1 min later)
...
case 708: /* There is a trigger signal here*/
{
result = APP_RES_PRG_OK;
system("echo '/sbin/stop' | at now + 1 min");
}
...
On the other hand, It works properly in case launching fooinit.rt manually from shell as a ordinary command. (not from /etc/init.d/boot.local). So kill -9 work and terminates fooinit.rt process
Do you have any idea why kill -9 can not terminate foo.rt process if it is launched from /etc/init.d/boot.local
Your solution is built around a race condition. There is no guarantee it will kill the right process (an unknowable amount of time can pass between the ps call and the attempt to make use of the pid), plus it's also vulnerable to a tmp exploit: someone could create a few thousand symlinks under /tmp called "gdg_list[1-32767]" that point to /etc/shadow and your script would overwrite /etc/shadow if it runs as root.
Another potential problem is the setting of $USER -- have you made sure it's correct? Your at job will be called as the user your C program runs as, which may not be the same user your fooinit.rt runs as.
Also, your script doesn't include a kill command at all.
A much cleaner way of doing this would be to run your fooinit.rt under some process supervisor like runit and use runit to shut it down when it's no longer needed. That avoids the pid bingo as well as the /tmp attack vector.
But even using pkill -u username -f fooinit.rt would be less racy than the script you provided.