My JIRA server occasionally dies. I've not been able to find any 'out of memory' errors, or anything else in the logs that would explain this. So I give up and do the following little script:
#/bin/sh #### script to check every ten minutes if JIRA is up and restart it if it isn't mailPerson="email@example.com statusFile="/tmp/status" /bin/ps -ef |/bin/grep -q jira lastStatus=$? if [ $lastStatus != "0" ]; then /etc/init.d/jira start statusStatus="The JIRA service was down" /bin/cat << EOF > $statusFile I have just had to restart JIRA!! EOF /bin/cat $statusFile | mail -s "$statusStatus" $mailPerson fi exit 0
I set this in root's cron, and set it for every ten minutes.
In a nutshell: it doesn't work.
The same script is running for Confluence (with the ps suitably altered), and that doesn't work either.
Your double quotes on 0 are correct. I believe you are expecting a wrong return from the $? variable.
Have a look in my example:
[root@jira-clone ~]# ls /tmp VMwareDnD atlassian-confluence-5.8.4-x64.bin hsperfdata_root pluginversioncheckerthing pulse-Pzck7gM0mRUD ssl ssl2 status vmware-root vmware-root-1857948889 [root@jira-clone ~]# [root@jira-clone ~]# echo $? 0 [root@jira-clone ~]# [root@jira-clone ~]# ls /directory-doesnt-exist ls: cannot access /directory-doesnt-exist: No such file or directory [root@jira-clone ~]# [root@jira-clone ~]# echo $? 2 [root@jira-clone ~]#
Exit status is a numerical value returned by every command upon its completion. As a rule, most commands return an exit status of 0 if they were successful, and 1 if they were unsuccessful.
Some commands return additional exit statuses for particular reasons. For example, some commands differentiate between kinds of errors and will return various exit values depending on the specific type of failure.
I've made some tests, and I believe what is causing this bad behaviour is your -q parameter. Try to run your script with no -q parameter on grep.
Another thing you can do to start your scripts and run them in debug mode. You just need to add -x after /bin/sh: Like this:
Hope this helps.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs