Finding which process was killed by Linux OOM killer [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
Improve this question
When Linux runs out of memory (OOM), the OOM killer chooses a process to kill based on some heuristics (it's an interesting read: http://lwn.net/Articles/317814/).
How can one programmatically determine which processes have recently been killed by the OOM killer?

Try this so you don't need to worry about where your logs are:
dmesg -T | egrep -i 'killed process'
-T, --ctime - Print human-readable timestamps.

Try this out:
grep -i 'killed process' /var/log/messages

Now dstat provides the feature to find out in your running system which process is candidate for getting killed by oom mechanism
dstat --top-oom
--out-of-memory---
kill score
java 77
java 77
java 77
and as per man page
--top-oom
show process that will be killed by OOM the first

Try this out:
grep "Killed process" /var/log/syslog

Related

How to see who kills execution of the script? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
There's a complicated script that starts other scripts. It all runs for about 6 hours. But I've noticed that one or two child scripts are being killed from time to time.
All I get is a line in log saying that script is killed.
How do I get some info on who kills it? Is it possible?
The nature of killing a process does not provide an originator. A bit is set in a kernel structure associated with the process, indicating a signal is pending. If the signalling process does not indicate it is signalling, there's no way to find out.
Some processes do in fact announce their signalling. On Linux, the OOM (Out of Memory) killer might write a log entry to /var/log/messages. If the reason for the signalling to your script is an OOM condition, this might be the place to look.
See also Who "Killed" my process and why?

last | reboot in linux rebooted the machine, can someone explain why ? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
how does the pipeline work in the below?
last | reboot
The above rebooted the linux machine.
last search the last logged in user and last output is given to reboot and reboot will reboot the system.
last | reboot
| | => process1 output will be input
process1 process2 for process2
See the man 1 last it says
Last searches back through the file /var/log/wtmp (or the file
desigā€
nated by the -f flag) and displays a list of all users logged in (and
out) since that file was created.
As Daniel says importantly, reboot doesn't care about its input. It probably doesn't read it at all, so piping something in doesn't change its behavior.

Pkill guarantees [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Can pkill guarantee the following situation never happens:
I use pkill -f "abc"
pkill finds process by name and remembers pid
process ends
Linux starts a new process with the same pid
pkill kills the process started at step 4
Pids do wrap and do eventually get reused. However, pids assigned to recently running processes are not soon reused.
so, in practice the problem you're worried about never happens.
It is theoretically possible as far as I can tell.
However, that would mean that
pkill was running slow enough that a whole bunch of new process IDs could get allocated between finding the process and killing it
the rest of the system was running fast enough to create all those processes and get to a point where the recently used pid was freed.
As pointed out in comments, either you are root or the process is running as the same user
It's possible there is some way of attacking pkill so it's that slow, but such an attack would almost certainly be a kernel bug.
I've never been in a situation where worrying about this problem was the right design decision.

Difference between qdel and kill commands [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Are there any differences between running qdel command or kill-9 to kill a job that is running using several compute nodes on a HPC cluster?
The effect of kill -9 seems to be immediate while qdel takes 5-10 minutes to change the job status from running (R) to canceled (C) before it stops.
kill -9 is a sledgehammer, machine gun and nuclear bomb all wrapped in one. Processes killed by kill -9 get no chance to clean up any resources they may have allocated. kill -9 will not directly remove your jobs from the job queue.
Think of kill -9 as the zombies in World War Z. Kill at all costs, no matter what.
As I understand it, qdel is a little more friendly in that it does 2 things, not necessarily in the order listed.
a controlled stop of a job and allows it to clean up
removes the job from the job queue
You can think of qdel as Dr. Kevorkian... He's all nice and friendly and wants to help you so he cooperates to a point... But ultimately, he's there to kill you too.

Check the main memory usage by a linux command [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Is there any command that I could use to check the memory usage for a single linux command? For instance I have a script file (test.sh) which will read and extract word from a 100mb text file. How could I know how much memory does this command (./test.sh input_file.txt) would take?
Thanks for the advises there!!
Use the free command to check the usage of RAM.
To check the size of the program in memory you can check the /proc/[pid]/statm file. For details of the format of this file read man proc
Fetch the PID of the script from the script using the $$ variable (in bash).
EDIT
Other solutions:
ps u $PID | tail -n1 | tr -s ' ' | cut -d ' ' -f 5,6 Gives you the VMZ and RSS of the process with $PID.
Or may want to like to see only the process memory using
watch -n0.5 ps u $PID
this will update the usage of the memory for your process every 0.5 secs. Adjust the value for updating as required.
You can just use top to see that. When you execute your script, a shell process such as bash, will be create to execute the script for you. So, find the shell process in top and you can see how many memory it uses.

Resources