19
votes
Accepted
How to prevent "ps" reporting its own process?
My answer is a variation on the typical answer for searching for "foobar" in a ps listing. The argument of "-A" "ps" is more portable than "aux", I believe, but this change is irrelevant to the answer....
- 346
17
votes
Show full process name in top
top -c -n 1 should give you what you want.
-c: automatically toggles between command line and program name
-n 1: this makes top to exit out immediately without showing the updates every 3 seconds (by ...
- 271
13
votes
Accepted
Linux: ps command's output is randomly different than expected, can you find the reason?
man ps, section etime:
etime ELAPSED elapsed time since the process was started, in the form [[dd-]hh:]mm:ss.
So your process runs for longer than a day.
- 97.9k
10
votes
8
votes
Unix / Linux command to see finished or killed processes
You can find that information in the system log
/var/log/syslog and /var/log/messages
Depending on what process they were you may be able to find some info about their start time etc.
ex:
Feb 1 ...
- 238
6
votes
Accepted
extra sshd root instance
In this example you see this pair of processes:
root 12401 476 0 23:27 ? 00:00:00 \_ sshd: root [priv]
sshd 12402 12401 0 23:27 ? 00:00:00 \_ sshd: root [net]
which is ...
- 9,375
5
votes
Accepted
How to get ps output with headers
I am not sure headers is needed.
the headers are printed, but are filtred out by grep.
awk solution
ps aux --headers| awk 'NR==1 || /awk/ '
NR==1 keep first line
|| or
/awk/ line with awk
egrep ...
- 1,359
4
votes
Accepted
ps is giving a segmentation fault
Try to increment the user stack size, the default on my Linux workstation is:
stack size (kbytes, -s) 8192
- 5,209
4
votes
How to get the path details from the proccess ID?
The most direct Solaris equivalent is /proc/<pid>/path/a.out For example:
% ls -l /proc/$$/path/a.out
lrwxrwxrwx 1 alanc staff 0 Mar 13 21:16 /proc/2892/path/a.out -> /usr/bin/...
- 1,500
3
votes
Accepted
How can I know the absolute path of a running process? on solaris
You can use pwdx in solaris and linux.
pwdx <pid_number>
example:
pwdx $$
25711: /export/home/pippo
- 5,209
3
votes
How to cut the result of ps command
Run it per partes and you see how the output changes. (it should be safe in this case)
ps -laef
ps -laef | cut -c 48-
ps -laef | cut -c 48- | sort
ps -laef | cut -c 48- | sort | uniq -c
ps -laef |...
- 3,927
3
votes
How can I know the absolute path of a running process? on solaris
How can I know the absolute path of a running process?
If by "absolute path" you mean the full path of the running binary, this works on my installed copy of Solaris 11:
pmap PID | grep -v ':' | ...
- 1,252
3
votes
busybox - how to list process priority?
If you have a cut-down Linux distribution where ps and top does not give you priority information, you can parse the stat file of proc for your process ID to get the priority information.
cat /proc/...
- 211
3
votes
Accepted
how to find Linux processes started at a certain time
$ ls -lah /proc
...all of the numeric items in that directory are proccess IDs. Look at the create time for each, and you have when each process was started.
The only way you'd be able to ...
- 109k
3
votes
User shown in ps does not exist
Use n parameter, described in manual page:
n Numeric output for WCHAN and USER (including all types of UID and GID)
e.g
ps -ef n
N.B. there should be space, not dash before n
- 251
3
votes
Accepted
Why does `ps -x | grep foo` include the grep command?
As Bravo points out, a pipe in Linux is not a file, it is dynamic. So ps -x | grep login will actually start both programs at once, so that one can pitch down the pipe and the other can catch. The ...
- 355
2
votes
How to prevent "ps" reporting its own process?
This only occurs to me when running inside an ssh "script" command or when using remote management tools.
I don't like the hackiness of the previous solutions.
I'm not sure if what I've come ...
- 21
2
votes
How to find full process arguments and associated listening ports?
I was getting errors from ps on Ubuntu 16.04 when using Mark Sturgill's answer as-is. Needed a slight modification to make it work: basically added an extra split to further isolate the numeric PID ...
- 153
2
votes
Accepted
How to get the path details from the proccess ID?
I'M THE AUTHOR AND THIS ANSWER IS INCORRECT AND SHOULD BE DELETED (cannot delete as it is the accepted answer). As pointed out in comments below
it will return the process' working directory, aka ...
- 257
2
votes
Accepted
Print last column containing spaces and special characters
The error is here: awk '$2 == '"$PID"
if $PID is not strictly numeric, then you're doing an equality check against an unquoted string, so really, who knows how awk will interpret it?
$ PID="3000)"
$ ...
- 4,425
2
votes
How to change time format to seconds in ps -p?
This will give output in seconds on Ubuntu. It does not work on RedHat.
ps -p PID -o etimes=
- 184
2
votes
Accepted
How to change time format to seconds in ps -p?
You can try something like:
time=$(ps -p $processid -o etime= | tr -d ' ');
time_in_seconds=$(case ${#time} in "8") echo ${time: -2}+${time: -5:2}*60+${time: -8:2}*3600 | bc;; "5") echo ${time: -2}+...
- 2,246
2
votes
Wchan section in ps output not showing anything
There are several possibly reasons for wchan being reported as - by ps:
the process just isn't blocked in the kernel, i.e. it's running (cf. the ps state column)
the stack walking procedure fails due ...
- 784
2
votes
Wchan section in ps output not showing anything
in the newer linux kernel you see in which kernel function your process is stuck
cat /proc/<pid_numer>/stack
- 5,209
2
votes
How to terminate a process(httpd) when its PID keeps on changing in CENTOS 7
Try:
find / -name "httpd.pid"
Then delete the pid file, if it exists.
Also, just in case:
systemctl stop httpd
systemctl disable httpd
Machavity is right too, whenever you grep from the ...
- 172
2
votes
Accepted
How to terminate a process(httpd) when its PID keeps on changing in CENTOS 7
You have to understand that when you grep httpd you'll not just get back any apache processes but the grep process as well. You're seeing your own command reflected back at you.
# ps ax | grep ...
- 846
2
votes
How to ensure that the script and its command get killed once terminal is closed
Your script is run on another shell and uses the -f option (follow) of tail which appends the output as the file grows. In short, the script has no exit point, so it's not supposed to end, even if ...
- 1,055
2
votes
Unix / Linux command to see finished or killed processes
If you don't have things set up ahead of time you won't get what you need, but psacct keeps track of processes, but you have to make sure of storage. Then you would use lastcomm and all kinds of ...
- 1,663
2
votes
How to combine lsof stat and ps to get more info in one line bash command
If you use awk to print $1 (the command) and $2 (the PID) in reverse order ($2, $1) this provides most of the information you want in a usable format. The first sort and uniq -c still work as expected ...
- 115k
2
votes
ps output is not correlated to free command?
I had the exact same situation. htop and top both reported about 95% usage (excluding buffers/caches) as did free -m. When summing up the processes from ps, I only was using about 10% of the memory. I ...
- 121
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
ps × 127linux × 57
process × 24
top × 18
ubuntu × 15
bash × 12
apache-2.2 × 7
centos × 7
memory × 7
debian × 6
grep × 6
unix × 5
php × 4
netstat × 4
security × 3
monitoring × 3
mac-osx × 3
command-line-interface × 3
httpd × 3
shell × 3
solaris × 3
kernel × 3
cpu-usage × 3
awk × 3
kill × 3