We changed our privacy policy. Read more.

Questions tagged [pgrep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
60 views

Why pgrep hangs when clang AddressSanitizer library is preloaded using LD_PRELOAD?

I noticed that when I set LD_PRELOAD env. variable to libclang_rt.asan-x86_64.so pgrep hangs. Why is this happening and how to avoid this? senx:/$ time pgrep anything real 0m0,022s user 0m0,...
2
votes
0answers
94 views

Why is pgrep/pkill so much slower than ps?

I would have thought that pgrep would be much faster than ps -ef yet the contrary is true - pgrep takes about 4x longer. But only on my laptop e.g.: $ time { ps -ef |grep foobar; } real 0m0.027s ...
0
votes
1answer
68 views

IF statment for checking if arecord is working inside a shell script no responding well

I wrote a script that should check if the arecord command line audio recorder is not working, and if so it should start it. With the help of cron, I want to verify that I'm recording within a specific ...
1
vote
1answer
56 views

How to get a list of process ids of long command names, not command line parameters?

Since there's a 15-character limit on the length of process names in pgrep, I've been using pgrep -f to give me a list of process id's of running commands with longer names. However, it includes the ...
1
vote
1answer
121 views

how to write a pgrep pattern that (never) matches a zero byte?

I'd like to kill a process with a long name that ends with foo. Currently my plan is to use pkill (though for testing, to be friendly to the process, I've been checking my patterns with pgrep instead)....
3
votes
2answers
616 views

Why doesn't "pgrep firefox" work on Ubuntu 20.04

As the title suggests, the following command on Ubuntu 20.04: pgrep firefox ... returns no results. Meanwhile, the following command: ps aux |grep firefox ... returns 6 results, 5 of which should ...
2
votes
2answers
329 views

pgrep -f exits with 1

RUNNING_APPS=$(pgrep -f "somePattern") echo $? #results in 1 How can I make my command pass with exit code 0?
0
votes
1answer
94 views

Suspicious pgrep run as root user on debian bullseye

I experience quite a bit of fan activity on my laptop, even the machine should be idle. When I take a look at my processes with top I have a pgrep process appear once in a while, taking some CPU. It ...
2
votes
1answer
120 views

Trying to optimize CPU usage, 'pgrep -x spotify' running despite never installing spotify

I recently installed Arch Linux on a very old laptop. As such, I am trying to optimize it as much as possible and cut down on CPU/RAM usage. Attached is a screenshot I took of htop on the laptop ...
-2
votes
1answer
1k views

What are the differences between pgrep and `ps aux | grep`?

Why is pgrep needed? If we can use ps and grep together, why do we need pgrep? It'd be weird if we have a command lsgrep or curlgrep. But one difference I noticed was, if we first start a tmux ...
2
votes
1answer
680 views

How to get pkill to output process information of killed process?

How to get pkill to output process information of killed process? I don't see anything in man pkill that suggests this is possible. I know I can do a pgrep and process the list and then pipe that to ...
1
vote
0answers
79 views

pgrep -f matches on first 4096 characters only

pgrep on a Ubuntu 19.10 matches on a cmd line of about 10000 characters just fine, but the same version (see below) of pgrep on Debian 10 (buster) greps only on the first 4096 characters. Is there a ...
5
votes
2answers
4k views

Why can't I get pgrep output right to variable on bash script?

I'm trying to make a script to either quit compton if it's running or start it if it's not running. I've read from man that it should exit 1 if process is found, so I've tried to make a script that ...
1
vote
1answer
651 views

Cron watchdog for a python script

I have a python script that should be restarted automatically every time it fails. I've trying to use for this purpose cron with the following setting: */2 * * * * pgrep -f handler.py || /usr/bin/...
1
vote
1answer
1k views

pgrep returns different results if run from script than if run in terminal

I have written a script to check how many instances of a process are running in an OpenWrt based system. If I run the following in my terminal COUNT_PS=$(echo `ps -w | grep -v grep | grep upmpdcli | ...
0
votes
1answer
287 views

Getting different results running same commands step by step at a terminal and within a script [duplicate]

pid=$(pgrep 'engrampa') #Get the PID of the engrampa processes . killpid=$(echo $pid | head -1) #Get only the first line of the $pid variable and put into a new variable called $killpid. kill $killpid ...
2
votes
1answer
1k views

Cron job won't run (pgrep issue)

I'm running a cron job every minute, which launches a bash shell script: # Automatically reboot the server if it goes down * * * * * /root/auto-restart.sh I can manually run the script, but whenever ...
1
vote
3answers
3k views

Does `ps` provide the working directory of each process?

Is it correct that the output of jobs contains the working directory when invoking each job (not necessarily the current working directory of each job)? $ jobs -l | grep JDBC [15] 20422 Running ...
6
votes
1answer
3k views

How do I check with a Bash script if an application is running?

I have a gnome-run application in my home folder. I have now added the application to run when I press Meta+R (I added it in in CCSM). I run the application by executing ./gnome-run in my home folder. ...