The JIRA instance I am in charge of is quite large. Well north of 800,000 issues large.
This means when it is time to re-index that instance it takes quite a while – several hours. Because of the 24 hour nature of the business, I have a need to re-index it at odd hours – like 1AM on a Sunday. As it turns out, I like to sleep at those same odd hours.
In order to facilitate that, I wrote a script to kick off that re-index automatically. I can then run that script via a crontab.
Here is the script I wrote – you will need to season this to your environment. The USER needs to be a jira-administrator, I use a local JIRA account (versus an LDAP based one). I also connect directly to the tomcat port rather than the Apache re-director running on port 80.
#!/bin/bash ### SETTINGS ### USERNAME=JIRA-ADMIN PASSWORD=JIRA-ADMIN-PASSWORD JIRA_HOST=jira.example.priv:8080 DASHBOARD_PAGE_URL=http://$JIRA_HOST/secure/Dashboard.jspa WEBSUDO_PAGE_URL=http://$JIRA_HOST/secure/admin/WebSudoAuthenticate.jspa INDEX_PAGE_URL=http://$JIRA_HOST/secure/admin/jira/IndexReIndex.jspa COOKIE_FILE_LOCATION=/tmp/jiracoookie LOG_FILE=/usr/local/jira/bin/log.txt ### COMMANDS ### curl -u $USERNAME:$PASSWORD --cookie-jar $COOKIE_FILE_LOCATION $DASHBOARD_PAGE_URL --output $LOG_FILE GREP=$(grep 'HTTP Status 401 - Basic Authentication Failure - Reason : AUTHENTICATION_DENIED' $LOG_FILE) if [ -z "$GREP" ];then curl -s --cookie $COOKIE_FILE_LOCATION -d "webSudoPassword=$PASSWORD" $WEBSUDO_PAGE_URL --output $LOG_FILE curl --cookie $COOKIE_FILE_LOCATION --header "X-Atlassian-Token: no-check" -d "indexPathOption=DEFAULT" -d "Re-Index=Re-Index" -d "indexPath=" $INDEX_PAGE_URL --output $LOG_FILE else echo "Password is outdated." echo "JIRA response: $GREP" fi /bin/rm -f $COOKIE_FILE_LOCATION DATE=$(date) echo $DATE >> /usr/local/jira/bin/reindex.log
Once the script is setup, it can be manually run or can be scheduled via a cron.