Error while running restart script -


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error while running restart script -
# 1  
Old 03-13-2013
Error while running restart script -

Hi All

I have written below basic restart script but it is giving me the following error -

error - syntax error at line 40 : `else' is not matched .

below is the script can someone assist me what i am doing wrong -

Code:
#!/bin/ksh

cd bin

. ./set_sysm

sleep 60

./swstop -f 0

sleep 600

../util/show_processes > /tmp/k.log

/tmp/COUNT=`cat /tmp/k.log | grep -c "SHUTTING DOWN"` 

if [ $/tmp/COUNT = 10 ];

then

./swstop -p

sleep 60

./swstart -p

sleep 600

../util/show_processes > /tmp/k2.log

/tmp/COUNT1=`cat /tmp/k2.log | grep -c "SHUTTING DOWN"`

if [ $/tmp/COUNT1 = 10 ];

then

echo "application is up and is in running mode" | mailx -r application@mail.com -s "application is up" honey@mail.com

cat /tmp/kunal2.log | mailx -r application@mail.com -s "application output result" honey@mail.com

else 

echo "application is up and is in running mode" | mailx -r application@mail.com -s "application is up" honey@mail.com

cat /tmp/kunal2.log | mailx -r application@mail.com -s "application output result" honey@mail.com
 
fi

else

echo "application processes are not coming down" | mailx -r application@mail.com -s "Urgent application processes are not coming down - Follow manual procedure" honey@mail.com

exit

fi


The script basically stops the processes check if all are down , Start the process and check if all are up .

Please assist .

Last edited by Corona688; 03-13-2013 at 02:29 PM.. Reason: code tags...
# 2  
Old 03-13-2013
Hi, your code have some mistakes. Try these changes, and indent your code

Code:
#!/bin/ksh
cd bin
. ./set_sysm
sleep 60
./swstop -f 0
sleep 600
../util/show_processes > /tmp/k.log
$COUNT=`cat /tmp/k.log | grep -c "SHUTTING DOWN"` 
if [ $COUNT -eq 10 ]
then
	./swstop -p
	sleep 60
	./swstart -p
	sleep 600
	../util/show_processes > /tmp/k2.log
	$COUNT1=`cat /tmp/k2.log | grep -c "SHUTTING DOWN"`
	if [ $COUNT1 -eq 10 ]
	then
		echo "application is up and is in running mode" | mailx -r application@mail.com -s "application is up" honey@mail.com
		cat /tmp/kunal2.log | mailx -r application@mail.com -s "application output result" honey@mail.com
	else 
		echo "application is up and is in running mode" | mailx -r application@mail.com -s "application is up" honey@mail.com
		cat /tmp/kunal2.log | mailx -r application@mail.com -s "application output result" honey@mail.com
	fi
else
	echo "application processes are not coming down" | mailx -r application@mail.com -s "Urgent application processes are not coming down - Follow manual procedure" honey@mail.com
	exit
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Service restart and check if running

Hello, I'l like to create a script that restart a service (/etc/init.d/httpd restart) and also check if after restart the service is actually running. Sometimes it happen that at the first try the service fails to restart. Thanks (2 Replies)
Discussion started by: bazzola
2 Replies

2. Shell Programming and Scripting

Error running script

Hi, I have the the below script more runcda.sh if *\).*/\1/p' $1_dr) ]; then echo "ParallelGCThreads Found with Value" else echo "ParallelGCThreads Not Found - Add !!" fi $ ./runcda.sh output.log ./runcda.sh: test: argument expected ParallelGCThreads Not Found - Add !! Why am i... (2 Replies)
Discussion started by: mohtashims
2 Replies

3. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

4. Shell Programming and Scripting

Script to restart apache when running out of memory

Hi, I have a problem with running out of memory in my Ubuntu web server (4GB RAM) because many people try to access my server. I used to restart manually my apache server to clear out the memory & swap. Can anyone tell me how to write bash script that can automatically restart apache when... (2 Replies)
Discussion started by: nica
2 Replies

5. Shell Programming and Scripting

How to keep process running after apache restart.

I have posted this on the Web subforum but it seems that nobody knows to do this, maybe someone has a solution here. Thank you I have a PHP application that starts a couple of processes on the server...the problem is that if I restart apache those running apps will die. How can I start them... (1 Reply)
Discussion started by: valiadi
1 Replies

6. Web Development

How to keep process running after apache restart.

Hi, I have a PHP application that starts a couple of processes on the server...the problem is that if I restart apache those running apps will die. How can I start them in a way that they are not killed when I restart/stop apache ? $cmdstr = "nohup ".$config."/".$config."... (6 Replies)
Discussion started by: valiadi
6 Replies

7. Red Hat

error running postrotate script

Hi, I am getiing emails from cron.daily with subject: Cron root@vsftp run-parts /etc/cron.daily /etc/cron.daily/logrotate: /sbin/killall -HUP radiusd : line 1: /sbin/killall: No such file or directory error: error running postrotate script for /var/log/vsftpd/logfile the... (6 Replies)
Discussion started by: renuka
6 Replies

8. Solaris

Error when running script

Hi All, Need your guuys help here. #!/bin/bash { echo "POLICY LIST" echo "====================================" bppllist echo " " echo "POLICY DETAILS" echo "====================================" for type in daily weekly monthly quarterly echo... (6 Replies)
Discussion started by: ronny_nch
6 Replies

9. Shell Programming and Scripting

error in in running script

Hi all, I have created a script file .sh and had some allias commands, local variable, some grep features, and listing files/directories, and it worked correctly and I got the outputs I am looking for after I run the script . However, some of the grep commands and some other functions did not... (2 Replies)
Discussion started by: aama100
2 Replies

10. UNIX for Dummies Questions & Answers

Error while running a script

Hi all, By running a (command) script I'm getting the following error: .: /usr/bin/test: cannot execute binary file This is the command: $ . test The script (test) is very simple sqlplus user/password @1.sql sqlplus user/password @2.sql Can enyone tell me what the problem is. (5 Replies)
Discussion started by: HarryTellegen
5 Replies
Login or Register to Ask a Question