Tim Dunphy bluethu...@gmail.com a écrit :
Hey all,
Hi,
-e checks file existence. As you don’t have a file named 26979 in your
pwd, test fails logically.
If you want to know if variable is set, you can use -z $pid. You could
also try -d /proc/$pid.
HTH,
Laurent.
On Sun, 2015-04-19 at 13:15 -0400, Tim Dunphy wrote:
Hey all,
I wrote a very basic script to determine if cassandra db is running. I'm
setting a variable called 'pid' to the output of a ps | grep like to grab
the pid of the cassandra process.
Insert an extra line after #!/bin/bash
set
On Sun, Apr 19, 2015 at 01:15:36PM -0400, Tim Dunphy wrote:
if [[ -e $pid ]]
-e means if file exists. You should use -n
--
rgds
Stephen
___
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
Hey all,
I wrote a very basic script to determine if cassandra db is running. I'm
setting a variable called 'pid' to the output of a ps | grep like to grab
the pid of the cassandra process.
#!/bin/bash
pid=$(ps -ef | grep cassandra | grep -v grep | grep -i -v -e grep -e screen
-e s3fs|awk
On Sun, Apr 19, 2015 at 09:40:29PM -0400, Tim Dunphy wrote:
Good tip! But I ran the script with sh +x . I guess that running it with sh
You should use bash -x (bash and not sh because sh may not be bash
everywhere; eg Ubuntu; -x and not +x because -x means turn on debug
but +x means turn _off_
On Sun, Apr 19, 2015 at 09:00:06PM -0500, Chris Adams wrote:
Once upon a time, Stephen Harris li...@spuddy.org said:
You should use bash -x (bash and not sh because sh may not be bash
everywhere; eg Ubuntu; -x and not +x because -x means turn on debug
but +x means turn _off_ debug)
-e means if file exists. You should use -n
That did it!!
[root@web1:~] #./bin/check-cass.sh
Cassandra is running with pid: 26979
This is what the script looks like now:
#!/bin/bash
pid=$(ps -ef | grep cassandra | grep -v grep | grep -i -v -e grep -e screen
-e s3fs|awk '{print $2}')
if [[
Once upon a time, Tim Dunphy bluethu...@gmail.com said:
pid=$(ps -ef | grep cassandra | grep -v grep | grep -i -v -e grep -e screen
-e s3fs|awk '{print $2}')
You can probably replace that with a much cleaner pid=$(pidof cassandra).
--
Chris Adams li...@cmadams.net
Once upon a time, Stephen Harris li...@spuddy.org said:
On Sun, Apr 19, 2015 at 09:40:29PM -0400, Tim Dunphy wrote:
Good tip! But I ran the script with sh +x . I guess that running it with sh
You should use bash -x (bash and not sh because sh may not be bash
everywhere; eg Ubuntu; -x and
It's a matter of consistency. The script began #!/bin/bash and so a
direct shell invocation should _also_ use the same command.
Good point. I'll try to keep that in mind.
Thank you,
Tim
On Sun, Apr 19, 2015 at 10:04 PM, Stephen Harris li...@spuddy.org wrote:
On Sun, Apr 19, 2015 at
You can probably replace that with a much cleaner pid=$(pidof cassandra).
Good to know! I hadn't heard of pidof before. However this is what I get
when I run it:
[root@web1:~] #pidof cassandra
[root@web1:~] #
Returns nothing. However:
[root@web1:~] #pidof java
27210 11418 10852
Gives me a
Once upon a time, Tim Dunphy bluethu...@gmail.com said:
Good to know! I hadn't heard of pidof before. However this is what I get
when I run it:
Try pid=$(pidof -x cassandra). Normal pidof calls look for programs
with the given name, but scripts/interpreted programs show up with the
interpreter
12 matches
Mail list logo