I am running below script on sles 11 and getting different output.
#!/bin/bash
PID=$(/bin/ps aux | grep sro-rest | grep -v grep | awk '{print $2}')
echo "PID = $PID"
. /etc/rc.status
PID=$(/bin/ps aux | grep sro-rest | grep -v grep | awk '{print $2}')
echo "PID = $PID"
Output:
PID = 2453
PID =
After debugging, I get to know that once we run . /etc/rc.status
then output of ps aux
is getting short.
See below script for example,
#!/bin/bash
echo "Before ==================================> "
/bin/ps aux | grep java | grep -v grep
. /etc/rc.status
echo "After ==================================> "
/bin/ps aux | grep java | grep -v grep
Output :
Before ==================================>
root 2453 4.9 7.8 8496196 615020 ? Sl Jun05 60:31 /usr/java/jre1.8.0_77//bin/java -Djava.net.preferIPv4Stack=true -Djava.library.path=/opt/sro/lib -Dserver.port=50000 -Dspring.profiles.active=gal -jar /opt/sro/ui/lib/sro-rest-SNAPSHOT.jar
After ==================================>
root 2453 4.9 7.8 8496196 615020 ? Sl Jun05 60:31 /usr/java/jre1.8.0_77//bin/java -Djava.net.preferIPv4Stack=true -Djava.l
Can anyone explain why different behavior for the same command?