Skip to main content

Questions tagged [pidof]

The tag has no summary, but it has a tag wiki.

1 vote
1 answer
429 views

Why was pidof and pgrep removed from OpenSuse 15.5?

In openSuse leap 15.5, there are no packages offering pidof? SysVinit-tools package were part of the OS bundle previosuly, but was removed in 15.5. So, is there any alternates without installing ...
Jagan's user avatar
  • 11
0 votes
1 answer
740 views

Running pidof in a function

I want to detect whether my script is already running, so I use this: pidof -o %PPID -x "$0" >/dev/null && echo 'already running!' && exit 1 That works. But I want it in ...
lonix's user avatar
  • 2,005
1 vote
0 answers
825 views

pidofproc or pidof working from init.d but not from /usr/sbin

I have a Linux service I'm supporting. It offers the usual start and stop commands. The designer created a wrapper command that is meant to control startup and retries of the main function. The ...
Sinc's user avatar
  • 193
4 votes
2 answers
4k views

Why is pidof not working?

In the output of ps aux, I can see the process just fine: # ps aux | grep diff root 7787 28.7 0.0 9368 4516 pts/3 D+ 13:56 20:33 diff -qr mnt/mnt/md/ mnt/mnt2/ root 13130 0.0 0.0 ...
Luc's user avatar
  • 4,000
0 votes
0 answers
564 views

<pidof> Command not showing all Java processes

I noticed that the command in my case, is not listing all Java processes. If I run pidof java I get one single pid as a response. On the other hand, if I run ps aux | grep [j]ava I get a three ...
chromechris's user avatar
0 votes
1 answer
1k views

Process name 'masked' by /usr/bin/python and /bin/su

I'm trying to use the pidof command to see my script is already running as I only want this executable if the script is not already running, however, it seems the pidof command is not returning the ...
Alan Kavanagh's user avatar
2 votes
1 answer
3k views

How do I check for the existence of a process without a failed exit code being returned?

I’m using Amazon Linux. I want to start a process provided one isn’t running already. This is a bash script I embed within a Jenkins Maven job. So I have pids=$(pidof /usr/bin/Xvfb) if [ ! -n "$...
Dave's user avatar
  • 2,808
1 vote
2 answers
4k views

Find ProcessID - pidof not working

I need to try and find the ProcessId of a process. Initially I was doing: application="/home/user/apps/appName.app" appPid=$(pidof -x $application) This worked fine. However, it now turns out that ...
IGGt's user avatar
  • 2,557
1 vote
3 answers
4k views

How can I format output of shell command

I combine top and pidof command: top -p $(pidof <process_name>) If pidof <process_name> return one id top command works. But if pidof <process_name> more than one ids top command ...
utarid's user avatar
  • 433
2 votes
1 answer
1k views

What could be happening between pidof and kill to cause "no such process"?

I've inherited quite a bit of code and am looking at a cron job that restarts a service once an hour, no other scripts touch this process and this code is ran. #The name of the process has been ...
Peter Turner's user avatar
  • 1,744
2 votes
3 answers
5k views

Are there any alternatives to pidof? (smaller footprint)

Well, I've just found out that with extensive usage of pidof in very short intervals, the seemingly tiny tool can be a great CPU hog. (Source: top) On my older machine, it can easily reach 30 percent ...
syntaxerror's user avatar
  • 2,426
10 votes
3 answers
11k views

Why pidof and pgrep are behaving differently?

I have a init script in /etc/init.d/myservice for initialize a service like this: ... start() { ... daemon /usr/sbin/myservice ... } stop() { ... pgrep myservice pidof myservice ps -ef ...
Pigueiras's user avatar
  • 203
5 votes
3 answers
8k views

How to poll existence of a background script correctly

I have a problem with the following kind of script: #!/bin/sh long_running_script.sh & while [ `pidof long_running_script.sh` ] do echo "." sleep 1 done The sript will start ...
SKi's user avatar
  • 153
2 votes
1 answer
2k views

Using `pidof` with `sh -c`

I was wondering why this command line does not print pidof sh: $ sh -c "var=`pidof sh` ; echo \$var; ps -H" This one prints 123 as expected $ sh -c "var=123 ; echo \$var; ps -H" I am on Ubuntu Linux....
Ankur Agarwal's user avatar