Tag Info

New answers tagged

1

Basically, it sounds like you want general advice on profiling an application's I/O at runtime. You've been doing this with /proc/$PID/io which will give you some sort of idea of how much bandwidth is being used between disk and memory for the application. Polling this file can give you a rough idea of what the process is doing but it's an incomplete picture ...


1

You can start command in background then get its pid via $! variable. Example: $ ls & cat /proc/$!/io [1] 6410 rchar: 7004 wchar: 0 syscr: 13 syscw: 0 read_bytes: 0 write_bytes: 0 cancelled_write_bytes: 0


2

Usually I try to keep things as simple as: kill $pid; sleep 5; kill -9 $pid Or you can search a process by its name if you like: pkill $pattern; sleep 5; pkill -9 $pattern This is handy when you are working in a terminal, but for scripting you may prefer a more sophisticated solution from another answer.


0

Put this in your ~/.bashrc file. Use it like this killany program_name. It will try to kill any program with a matching name. killany () { PS=$(ps aux) PIDS=$(echo "$PS" | \ awk -v proc="$1" '{ reg=proc; if(match($11$12$13$14,reg)) print $2 }') if [ -n "$PIDS" ]; then echo "killing pids '$PIDS'" kill $PIDS 2> /dev/null ...


-1

ps -u servername is the command to check the running processes in case there are more than one server For eg: ps -u server1


1

You are correct to suspect that there is a (small!) atomicity problem. No matter what method you use, whether it's a system-standard utility like start-stop-daemon, a roll-your-own PID file, using pkill to query and kill by user ID, by executable binary, or whatever, there is always an interval between finding what process you want to kill and giving that ...


0

ps [whatever options you like] $(cd /proc; ls -d [0-9]* | sort -n | tail -1)


2

ps -eo pid= | sort -rn | head -n1 would be POSIX. On Linux, process ids share the same namespace as the thread ids. There, you can do: ps -Leo tid= | sort -rn | head -n1 To get the highest thread or process id number.


2

This doesn't use ps, but parsing ps is likely to be difficult (not to mention non-portable). This ought to be easier (and at least a bit more portable): ( cd /proc; printf "%s\n" *; ) | sort -n | tail -n 1 That looks for the highest numbered directory inside /proc, which works because on many Unix systems there's one /proc/### directory per pid that ...



Top 50 recent answers are included