I am developing a shell script that checks whether HSQL database is running or not on Ubuntu 20.04 platfrom. So I am attaching the script. This script checks for the process with name HSQL. If the number of process including the 'ps -ef' command is 1 then there is no HSQL running. But while running the script it is always going to if block in all condition, not going to else block at all. Where am I going wrong? Could someone help?
Here is the script:
#!/bin/sh
export noOfProcess=`ps -ef|grep hsqldb |wc| head -n1 | awk '{print $1;}'`
#echo ${noOfProcess}
if [ ${noOfProcess}=1 ]
then
echo 'database is not running'
/home/priyatosh/test/hsqldb/hsqldb-2.5.0/hsqldb/runjsqldb.sh
else
echo 'database is already running'
fi
CodePudding user response:
Please provide a space near equal to sign. So make it if [ ${noOfProcess} = 1 ]