How can I check if a process is running a shell script?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
Given a process pid, how can I
check if the process is running a shell script?
if yes, how can I get the child process(es) which the script is running? by
pgrep -P <pid>
?
Thanks.
bash process
add a comment |Â
up vote
0
down vote
favorite
Given a process pid, how can I
check if the process is running a shell script?
if yes, how can I get the child process(es) which the script is running? by
pgrep -P <pid>
?
Thanks.
bash process
See this stackoverflow.com/questions/38275921/â¦
â Ujjwal Singh
Jul 28 at 1:31
Thanks. Mine is a bit different: given a pid.
â Tim
Jul 28 at 1:35
stackoverflow.com/q/3043978/10008752
â Ujjwal Singh
Jul 28 at 1:38
Thanks. How do you use them to answer my question?
â Tim
Jul 28 at 1:47
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Given a process pid, how can I
check if the process is running a shell script?
if yes, how can I get the child process(es) which the script is running? by
pgrep -P <pid>
?
Thanks.
bash process
Given a process pid, how can I
check if the process is running a shell script?
if yes, how can I get the child process(es) which the script is running? by
pgrep -P <pid>
?
Thanks.
bash process
edited Jul 28 at 1:35
asked Jul 28 at 1:25
Tim
22.5k61222398
22.5k61222398
See this stackoverflow.com/questions/38275921/â¦
â Ujjwal Singh
Jul 28 at 1:31
Thanks. Mine is a bit different: given a pid.
â Tim
Jul 28 at 1:35
stackoverflow.com/q/3043978/10008752
â Ujjwal Singh
Jul 28 at 1:38
Thanks. How do you use them to answer my question?
â Tim
Jul 28 at 1:47
add a comment |Â
See this stackoverflow.com/questions/38275921/â¦
â Ujjwal Singh
Jul 28 at 1:31
Thanks. Mine is a bit different: given a pid.
â Tim
Jul 28 at 1:35
stackoverflow.com/q/3043978/10008752
â Ujjwal Singh
Jul 28 at 1:38
Thanks. How do you use them to answer my question?
â Tim
Jul 28 at 1:47
See this stackoverflow.com/questions/38275921/â¦
â Ujjwal Singh
Jul 28 at 1:31
See this stackoverflow.com/questions/38275921/â¦
â Ujjwal Singh
Jul 28 at 1:31
Thanks. Mine is a bit different: given a pid.
â Tim
Jul 28 at 1:35
Thanks. Mine is a bit different: given a pid.
â Tim
Jul 28 at 1:35
stackoverflow.com/q/3043978/10008752
â Ujjwal Singh
Jul 28 at 1:38
stackoverflow.com/q/3043978/10008752
â Ujjwal Singh
Jul 28 at 1:38
Thanks. How do you use them to answer my question?
â Tim
Jul 28 at 1:47
Thanks. How do you use them to answer my question?
â Tim
Jul 28 at 1:47
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
When you execute a shell script, it will launch a process known as aÃÂ subshell. As a child process of the main shell, a subshell executes a list of commands in a shell script as a batch
(so-called "batch processing").
In some cases, you may want to know the process ID (PID) of the subshell where your shell script is running.
InÃÂ bash, theÃÂ PID of a shell script's subshell processÃÂ is stored in a special variable called '$$'. This variable is read-only, and you cannot modify it in a shell script. For example:
$ cat xyz.sh
#!/bin/bash
echo "PID of this script: $$"
Which gives the following output
PID of this script: XXXX
bashÃÂ shell exports several other read-only variables. For example, PPID stores the process ID of the subshell's parent process (i.e., main shell). UID stores the user ID of the current user who is executing the script. Like this(only example)
#!/bin/bash
echo "PID of this script: $$"
echo "PPID of this script: $PPID"
echo "UID of this script: $
Which gives the output
PID of this script: XXXX
PPID of this script: XXXX
UID of this script: XXXX
This is not answering the question posed, as the questioner pointed out in question comments. This is starting from having a shell script and finding its process ID. The question posed is starting from having a process ID and finding a shell script, if any. Note the first four words of the body of the question.
â JdeBP
Jul 28 at 10:55
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
When you execute a shell script, it will launch a process known as aÃÂ subshell. As a child process of the main shell, a subshell executes a list of commands in a shell script as a batch
(so-called "batch processing").
In some cases, you may want to know the process ID (PID) of the subshell where your shell script is running.
InÃÂ bash, theÃÂ PID of a shell script's subshell processÃÂ is stored in a special variable called '$$'. This variable is read-only, and you cannot modify it in a shell script. For example:
$ cat xyz.sh
#!/bin/bash
echo "PID of this script: $$"
Which gives the following output
PID of this script: XXXX
bashÃÂ shell exports several other read-only variables. For example, PPID stores the process ID of the subshell's parent process (i.e., main shell). UID stores the user ID of the current user who is executing the script. Like this(only example)
#!/bin/bash
echo "PID of this script: $$"
echo "PPID of this script: $PPID"
echo "UID of this script: $
Which gives the output
PID of this script: XXXX
PPID of this script: XXXX
UID of this script: XXXX
This is not answering the question posed, as the questioner pointed out in question comments. This is starting from having a shell script and finding its process ID. The question posed is starting from having a process ID and finding a shell script, if any. Note the first four words of the body of the question.
â JdeBP
Jul 28 at 10:55
add a comment |Â
up vote
0
down vote
When you execute a shell script, it will launch a process known as aÃÂ subshell. As a child process of the main shell, a subshell executes a list of commands in a shell script as a batch
(so-called "batch processing").
In some cases, you may want to know the process ID (PID) of the subshell where your shell script is running.
InÃÂ bash, theÃÂ PID of a shell script's subshell processÃÂ is stored in a special variable called '$$'. This variable is read-only, and you cannot modify it in a shell script. For example:
$ cat xyz.sh
#!/bin/bash
echo "PID of this script: $$"
Which gives the following output
PID of this script: XXXX
bashÃÂ shell exports several other read-only variables. For example, PPID stores the process ID of the subshell's parent process (i.e., main shell). UID stores the user ID of the current user who is executing the script. Like this(only example)
#!/bin/bash
echo "PID of this script: $$"
echo "PPID of this script: $PPID"
echo "UID of this script: $
Which gives the output
PID of this script: XXXX
PPID of this script: XXXX
UID of this script: XXXX
This is not answering the question posed, as the questioner pointed out in question comments. This is starting from having a shell script and finding its process ID. The question posed is starting from having a process ID and finding a shell script, if any. Note the first four words of the body of the question.
â JdeBP
Jul 28 at 10:55
add a comment |Â
up vote
0
down vote
up vote
0
down vote
When you execute a shell script, it will launch a process known as aÃÂ subshell. As a child process of the main shell, a subshell executes a list of commands in a shell script as a batch
(so-called "batch processing").
In some cases, you may want to know the process ID (PID) of the subshell where your shell script is running.
InÃÂ bash, theÃÂ PID of a shell script's subshell processÃÂ is stored in a special variable called '$$'. This variable is read-only, and you cannot modify it in a shell script. For example:
$ cat xyz.sh
#!/bin/bash
echo "PID of this script: $$"
Which gives the following output
PID of this script: XXXX
bashÃÂ shell exports several other read-only variables. For example, PPID stores the process ID of the subshell's parent process (i.e., main shell). UID stores the user ID of the current user who is executing the script. Like this(only example)
#!/bin/bash
echo "PID of this script: $$"
echo "PPID of this script: $PPID"
echo "UID of this script: $
Which gives the output
PID of this script: XXXX
PPID of this script: XXXX
UID of this script: XXXX
When you execute a shell script, it will launch a process known as aÃÂ subshell. As a child process of the main shell, a subshell executes a list of commands in a shell script as a batch
(so-called "batch processing").
In some cases, you may want to know the process ID (PID) of the subshell where your shell script is running.
InÃÂ bash, theÃÂ PID of a shell script's subshell processÃÂ is stored in a special variable called '$$'. This variable is read-only, and you cannot modify it in a shell script. For example:
$ cat xyz.sh
#!/bin/bash
echo "PID of this script: $$"
Which gives the following output
PID of this script: XXXX
bashÃÂ shell exports several other read-only variables. For example, PPID stores the process ID of the subshell's parent process (i.e., main shell). UID stores the user ID of the current user who is executing the script. Like this(only example)
#!/bin/bash
echo "PID of this script: $$"
echo "PPID of this script: $PPID"
echo "UID of this script: $
Which gives the output
PID of this script: XXXX
PPID of this script: XXXX
UID of this script: XXXX
answered Jul 28 at 2:13
Ujjwal Singh
6112
6112
This is not answering the question posed, as the questioner pointed out in question comments. This is starting from having a shell script and finding its process ID. The question posed is starting from having a process ID and finding a shell script, if any. Note the first four words of the body of the question.
â JdeBP
Jul 28 at 10:55
add a comment |Â
This is not answering the question posed, as the questioner pointed out in question comments. This is starting from having a shell script and finding its process ID. The question posed is starting from having a process ID and finding a shell script, if any. Note the first four words of the body of the question.
â JdeBP
Jul 28 at 10:55
This is not answering the question posed, as the questioner pointed out in question comments. This is starting from having a shell script and finding its process ID. The question posed is starting from having a process ID and finding a shell script, if any. Note the first four words of the body of the question.
â JdeBP
Jul 28 at 10:55
This is not answering the question posed, as the questioner pointed out in question comments. This is starting from having a shell script and finding its process ID. The question posed is starting from having a process ID and finding a shell script, if any. Note the first four words of the body of the question.
â JdeBP
Jul 28 at 10:55
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%2f458975%2fhow-can-i-check-if-a-process-is-running-a-shell-script%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
See this stackoverflow.com/questions/38275921/â¦
â Ujjwal Singh
Jul 28 at 1:31
Thanks. Mine is a bit different: given a pid.
â Tim
Jul 28 at 1:35
stackoverflow.com/q/3043978/10008752
â Ujjwal Singh
Jul 28 at 1:38
Thanks. How do you use them to answer my question?
â Tim
Jul 28 at 1:47