post#4 is unprecise (like post#1), for example will find pid 22 when searching for 2.
While the overall sense is not clear for me, this is certainly *not* intended.
Fix:
Doesn't give this the same result as the code in post#3 ?
No. It doesn't give the same result as the code in post #3. With slightly modified versions of these scripts: ./tester:
Note that this captures the output from ps in ps.out which will be used as input for the other two scripts instead of rerunning ps. The above script produces the output:
during a period where the command du / > du.out was running in the background while this script was running.
With this version of SkySmart's code modified to read from the ps.out produced by the above script: ./SkySmart:
and run with the operand 27189, we get the output:
which is identical to the output produced by the code in post #3. But with a similarly modified version of MadeInGermany's code: ./MadeInGermany:
and run with the operand 27189, we only get the output:
MadeInGermany's simpler code doesn't catch the parent, sibling, or grandchild processes of the process specified by $gpid. It only catches the process specified by $gpid and its children.
I do, however, agree that SkySmart's code works by accident when $gpid specifies a PID that isn't small enough to accidentally match several other unintended PIDs of unrelated running processes.
These 2 Users Gave Thanks to Don Cragun For This Post:
I am sending a kill comand to kill a process inside a SH script but I don`t want the user to notice it so I donīt want the message "1222 killed" to appear.
I`ve tried to redirect the standard output to /dev/null 2>&1 and also tried to use "nohup" but none of them was succesfull.
Can anyone... (1 Reply)
Good day :)
I recently checked some stuff on my gateway and discovered what I believe is an unneeded route entry.
# route -n
Kernel IP routing table
Destination Gateway Genmask ... Iface
287.265.45.0 0.0.0.0 255.255.255.0 ... eth0
192.168.0.0 0.0.0.0 ... (3 Replies)
Dear all,
Normally unix automatically record up to 500 the command lines whatever I put in. Does anyone knows how I can avoid this record, in another word, I dont want system remember what I typed in
thanks (2 Replies)
I am able to run the UNIX commands in a Windows box from a UNIX box through "SSH" functionality. But whenever the SSH connection is established between UNIX and Windows, password for windows box is being asked.
Is there a way to avoid asking password whenever the SSH connection is made? Can I... (1 Reply)
Hi...
I need a help in using the awk command or any other solution to avoid the usage of loops.
My question is :
I have a input like this :
field1|field2|field3|field4|field5|field6|field7|field8|field9
ex : 4000|testing|scenario|14450|500|320|450|200|100
where the... (2 Replies)
Sometimes we need a single instance of a script to run at a time. Meaning, the script itself should detects whether any instances of himself are still running and act accordingly.
When multiple instances of one script running, it’s easy to cause problems. I’ve ever seen that about 350 instances... (4 Replies)
Hi,
I have 2 queries
1 .when I run some unix command, I am getting the output of "time" at std output (screen)
for eg
zegrep <pattern> *.v.gz
I almost found the reason but not sure, if the no of files matching *.v.gz is more then I am getting the time command output at the... (5 Replies)
Hi Gurus,
I have requirement to run different task based on input value. the sample file as below:
file1 (contains code need to be run)
code
aaa1
aaa2
bbb
ccc
ddd
file2 (contains all codes and job name)
code job1 job2
aaa1, job_aa1, job_a2
aaa2, job_aa2, job_a2
aaa3,... (5 Replies)
mkdir logs
mkdir: Failed to make directory "logs"; File existsTo avoid this error i use the -p argument so it creates a folder only if it is does not exists like you see below.
mkdir -p logs In the similar manner i wish to avoid this error with ln command
ln -s /tmp/myfolder var
ln: cannot... (4 Replies)
Hi,
Here is my command
print $2 was meant to select the second column however, it is getting substituted with the second argument that was passed to the script.
Can you please tell me how can I resolve this ? (6 Replies)