6
votes
1answer
76 views

Format cputime for ps

I'm trying to write a script that can monitor a process's CPU usage over an interval (to create a graph). So far, this is the command I'm using ps -p $PROCID -o cputime,etimes My only concern is ...
4
votes
1answer
143 views

PS: what does “ps -o comm= -p $PPID” do

I have a script which does ps -o comm= -p $PPID. The explanation says this gets the parent process name. From the man page I found out -o means user defined format, comm means command and -p means ...
3
votes
2answers
298 views

How to count how many shell/terminals are running?

I´m trying to count how many shell or terminal windows are currently running. I tried ps a|grep bash; ps a|grep tty; But it can be inaccurate.
0
votes
1answer
54 views

Different representation of bash in 'ps -f' command [duplicate]

I have two bash running; one is Terminal application that runs bash, the other one is xterm application that runs bash. With ps -f, I have -bash one, and bash at the other. What makes this ...
0
votes
4answers
627 views

How to check the process along with its arguments in process list?

I have written a script where i need to pass several arguments with the same script, the script is being executed after a certain time using cron. In order to make sure that there are no multiple ...
2
votes
3answers
2k views

How is it possible to sort ps command's CPU field?

I'm trying to make a small command that will find the processes that use the most CPU power. Firstly, I use ps aux > file.txt and then cut -c 16-20 file.txt | sort -n | tail -5. The result I get ...
3
votes
2answers
324 views

Why can't pgrep find scripts started via env?

For example: $ cat foo.sh #!/usr/bin/env bash while true; do sleep 1 ; done $ ./foo.sh & $ pgrep foo.sh $ Contrast with: $ cat bar.sh #!/bin/bash while true; do sleep 1 ; done $ ./bar.sh & ...
1
vote
1answer
186 views

difference between bash, -bash and /bin/bash in ps output [duplicate]

Someone had spawned a while true loop in bash (logged in as root) on a server. It kept spawning processes, which fortunately exited but I needed to kill the parent. I came to know it was spawned ...
0
votes
2answers
91 views

Why the -u flag doesn't work for ps?

I'm executing the following ps command: root@dor-desktop:/home/dor# ps u -t "$(tty)" -u mysql USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND dor 2070 0.0 0.1 22436 ...
0
votes
1answer
459 views

ps | grep shows bad output in subshell with jobs running in the background

I am using bash. I have a file named "a2draw" that contains only 1 line: sleep 99999 I start it using this command: bash a2draw & Now, I know and understand the trick with square bracket ...
1
vote
2answers
174 views

receiving command as a parameter in bash

I have a following simple script called single-instance that executes the given command if there is no process under that command running. If I hard-code the command after the else statement, it has ...
3
votes
4answers
991 views

How to run java process to be seen not as 'java…' in processes list?

Is it possible to run a Java process in Linux in a way that it could be seen in ps as some sort of alias? It would be easier to restart it when it is down.