We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [pgrep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
2answers
940 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
198 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
190 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
37 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
397 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
861 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 ...