Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Simple Script to Check running Process

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 05-02-2011
Java Simple Script to Check running Process

Code:
#!/bin/sh

CHECK='ps aux | grep start.jar | grep -v grep | wc -l'

if [ $CHECK = 0 ]
then
	/usr/local/jre-1.7.0/bin/java - jar start.jar &
else
	
fi

Could anybody advise whats up with this code im trying to put this in as a cron job to check that solr search engine is running every 10secs and if its not start it. The script is giving me a error when i execute it.

Code:
'if' unmatched

Any advice would be great thanks!

William
# 2  
Old 05-02-2011
remove else and try
# 3  
Old 05-02-2011
Nope that threw another error?


Code:
check.sh[9]: [: aux: unexpected operator/operand

The previous error was where i tried to enter exit at the end rather than fi.

I have very limited scripting experience so im trying to get my head around why this wont work?

Thanks
# 4  
Old 05-02-2011
also
"$CHECK = 0" is wrong . should be $CHECK -eq 0
# 5  
Old 05-02-2011
Changed that aswell but it doesn't like the last line "FI"

Same error as before..
# 6  
Old 05-02-2011
check this

#!/bin/sh
CHECK='ps -aux | grep start.jar | grep -v grep | wc -l'
if [ $CHECK -eq 0 ]
then
/usr/local/jre-1.7.0/bin/java - jar start.jar &
fi
# 7  
Old 05-02-2011
Copied and Pasted that straight in but its still throwing an

Code:
unexpected operator/operand

on line 6 this time which is again the "fi"
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ksh script to check if certain process is running seekryts15 Shell Programming and Scripting 6 12-29-2014 12:41 PM
How to add conditional check of whether a process is running before doing rest of script? nbsparks Shell Programming and Scripting 14 09-23-2013 11:57 AM
How a process can check if a particular process is running on different machine? saurabhnsit2001 UNIX for Dummies Questions & Answers 2 06-02-2012 11:14 PM
need to check if the process is running shifahim Shell Programming and Scripting 8 08-18-2011 10:17 PM
Script to check running of process lovepujain Shell Programming and Scripting 2 04-25-2011 02:39 AM
How do I check if a process is running in C cprogdude Programming 1 10-12-2010 05:01 AM
How to write an expect script to check if a process is running? icchi Shell Programming and Scripting 5 10-27-2009 03:05 AM
script to check if process is running daydreamer Shell Programming and Scripting 2 01-28-2009 05:14 PM
how to check if a process is running in a server from shell script. debu UNIX for Advanced & Expert Users 2 01-24-2008 04:19 PM
script to check for a particular process and alert if its not running goks Shell Programming and Scripting 1 12-09-2005 04:11 AM


All times are GMT -4. The time now is 09:09 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password