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 the applictaion could run from a variety of locations, such as:
/home/user/apps/appName.app
/home/user/desktop/appName.app
/home/user/desktop/link to apps/appName.app
So I tried to simply do
application="appName.app"
appPid=$(pidof -x $application)
But this didn't find any matches. I assume that
pidof
requires a full path to match.
How else can I get the ProcessId?
- - -
I think I need to further explain.
If I do
ps aux | grep application.app
I get two results.
user 29912 . . . . /home/user/apps/application.app
user 12345 . . . . grep application.app
If I then do
var1=pgrep application.app
echo $var1
the result is blank. It should be 29912.
Asked by IGGt
(2547 rep)
Jan 13, 2016, 09:09 AM
Last activity: Jan 13, 2016, 09:56 AM
Last activity: Jan 13, 2016, 09:56 AM