ps command return nothing in function
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')
And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.
What could be the reason for the specific works on Suse and how can I fix it?
linux grep opensuse ps suse
add a comment |Â
up vote
1
down vote
favorite
I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')
And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.
What could be the reason for the specific works on Suse and how can I fix it?
linux grep opensuse ps suse
SUSE as well as Ubuntu haspidof
, see here.
â dessert
Nov 9 '17 at 17:00
2
You cannot have spaces around=
in a variable assignment.
â glenn jackman
Nov 9 '17 at 17:04
This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
â creedqq
Nov 9 '17 at 17:06
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')
And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.
What could be the reason for the specific works on Suse and how can I fix it?
linux grep opensuse ps suse
I have a function which required some process ID that needs further action.
I tried to get it via command
PID = $(ps axf | grep SOME_PATTERN | grep -v grep | awk 'print $1')
And it works on ubuntu and centos, but doesn't work on suse.
Although manually it works everywhere.
What could be the reason for the specific works on Suse and how can I fix it?
linux grep opensuse ps suse
edited Nov 9 '17 at 18:26
Jeff Schaller
32k849109
32k849109
asked Nov 9 '17 at 16:56
creedqq
82
82
SUSE as well as Ubuntu haspidof
, see here.
â dessert
Nov 9 '17 at 17:00
2
You cannot have spaces around=
in a variable assignment.
â glenn jackman
Nov 9 '17 at 17:04
This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
â creedqq
Nov 9 '17 at 17:06
add a comment |Â
SUSE as well as Ubuntu haspidof
, see here.
â dessert
Nov 9 '17 at 17:00
2
You cannot have spaces around=
in a variable assignment.
â glenn jackman
Nov 9 '17 at 17:04
This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
â creedqq
Nov 9 '17 at 17:06
SUSE as well as Ubuntu has
pidof
, see here.â dessert
Nov 9 '17 at 17:00
SUSE as well as Ubuntu has
pidof
, see here.â dessert
Nov 9 '17 at 17:00
2
2
You cannot have spaces around
=
in a variable assignment.â glenn jackman
Nov 9 '17 at 17:04
You cannot have spaces around
=
in a variable assignment.â glenn jackman
Nov 9 '17 at 17:04
This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
â creedqq
Nov 9 '17 at 17:06
This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
â creedqq
Nov 9 '17 at 17:06
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
You need to use pgrep
instead of ps axf
if you want to use it with watch
command. There is more extended explanation here
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
You need to use pgrep
instead of ps axf
if you want to use it with watch
command. There is more extended explanation here
add a comment |Â
up vote
3
down vote
accepted
You need to use pgrep
instead of ps axf
if you want to use it with watch
command. There is more extended explanation here
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
You need to use pgrep
instead of ps axf
if you want to use it with watch
command. There is more extended explanation here
You need to use pgrep
instead of ps axf
if you want to use it with watch
command. There is more extended explanation here
edited Nov 9 '17 at 17:11
fpmurphy1
2,231915
2,231915
answered Nov 9 '17 at 17:04
evilsun
462
462
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f403565%2fps-command-return-nothing-in-function%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
SUSE as well as Ubuntu has
pidof
, see here.â dessert
Nov 9 '17 at 17:00
2
You cannot have spaces around
=
in a variable assignment.â glenn jackman
Nov 9 '17 at 17:04
This is not the root cause, sorry for the misunderstanding, I accidentally put them in the post
â creedqq
Nov 9 '17 at 17:06