Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pgrep]

The tag has no usage guidance.

3
votes
2answers
293 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
94 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/...
0
votes
1answer
97 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
35 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 ...
1
vote
1answer
145 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 ...
0
votes
3answers
460 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 ...