Difference between revisions of "SUNScholar/Restart DSpace/14.04"

From Libopedia
Jump to navigation Jump to search
(Created page with "<center> '''BACK TO RESTART DSPACE''' </center>")
 
m
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
  '''[[SUNScholar/Restart DSpace|BACK TO RESTART DSPACE]]'''
 
  '''[[SUNScholar/Restart DSpace|BACK TO RESTART DSPACE]]'''
 
</center>
 
</center>
 +
===Configuration===
 +
[[SUNScholar/Prepare_Ubuntu/S01|Log in to your server]] as the '''dspace''' user and then become the '''root''' user.
 +
 +
sudo -i
 +
 +
Create a '''scripts''' folder in the '''/root''' folder.
 +
mkdir /root/scripts
 +
Create the restart script
 +
nano /root/scripts/restart-dspace
 +
Add the following to the '''restart-dspace''' script using copy and paste with "nano".
 +
<pre>
 +
#!/bin/bash
 +
## This script is to be used to restart DSpace
 +
 +
echo "Stop Tomcat"
 +
sudo service tomcat7 stop
 +
sleep 5
 +
sudo service tomcat7 stop
 +
sleep 5
 +
 +
echo "Restarting PostgreSQL"
 +
sudo service postgresql restart
 +
 +
echo "Cleaning out old xmlui cache files"
 +
sudo rm /var/lib/tomcat7/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.data
 +
sudo rm /var/lib/tomcat7/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.index
 +
 +
echo "Remove old catalina log file"
 +
sudo rm /var/log/tomcat7/catalina.out
 +
 +
#### Optional ####
 +
#Fix file and folder permissions. Uncomment below to enable.
 +
#echo "Fixing file permissions. Please wait..."
 +
#sudo chmod 0777 -R /home/dspace/config
 +
#sudo chmod 0777 -R /home/dspace/log
 +
#echo "Fixing file ownership. Please wait..."
 +
#sudo chown dspace.tomcat7 -R /home/dspace/config
 +
#sudo chown dspace.tomcat7 -R /home/dspace/log
 +
 +
echo "Start Tomcat"
 +
sudo service tomcat7 restart
 +
 +
echo "Restart complete: `date`" > /var/tmp/restart-dspace
 +
</pre>
 +
 +
{{NANO}}
 +
 +
Now make the script executeable
 +
 +
chmod 0755 /root/scripts/restart-dspace
 +
 +
===Manual Restart===
 +
Now run the script when needed by typing:
 +
sudo -i
 +
 +
/root/scripts/restart-dspace
 +
You can watch the restart by typing:
 +
tail -f /var/log/tomcat7/catalina.out
 +
To quit tailing the log file, type: <tt>'''CTL+c'''</tt>
 +
 +
===Automatic Restart===
 +
To automatically and regularly restart, add a '''root''' user cron job.
 +
 +
As the "root" user user type the following:
 +
crontab -e
 +
Copy and paste the following to the bottom of the file and then save the file:
 +
45 7 * * *    /root/scripts/restart-dspace
 +
This will restart DSpace 07:45 in the morning each day.
 +
 +
[[Category:System Administration]]

Latest revision as of 11:38, 28 May 2016

BACK TO RESTART DSPACE

Configuration

Log in to your server as the dspace user and then become the root user.

sudo -i

Create a scripts folder in the /root folder.

mkdir /root/scripts

Create the restart script

nano /root/scripts/restart-dspace

Add the following to the restart-dspace script using copy and paste with "nano".

#!/bin/bash
## This script is to be used to restart DSpace

echo "Stop Tomcat"
sudo service tomcat7 stop
sleep 5
sudo service tomcat7 stop
sleep 5

echo "Restarting PostgreSQL"
sudo service postgresql restart

echo "Cleaning out old xmlui cache files"
sudo rm /var/lib/tomcat7/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.data
sudo rm /var/lib/tomcat7/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.index

echo "Remove old catalina log file"
sudo rm /var/log/tomcat7/catalina.out

#### Optional ####
#Fix file and folder permissions. Uncomment below to enable.
#echo "Fixing file permissions. Please wait..."
#sudo chmod 0777 -R /home/dspace/config
#sudo chmod 0777 -R /home/dspace/log
#echo "Fixing file ownership. Please wait..."
#sudo chown dspace.tomcat7 -R /home/dspace/config
#sudo chown dspace.tomcat7 -R /home/dspace/log

echo "Start Tomcat"
sudo service tomcat7 restart

echo "Restart complete: `date`" > /var/tmp/restart-dspace

NANO Editor Help
CTL+O = Save the file and then press Enter
CTL+X = Exit "nano"
CTL+K = Delete line
CTL+U = Undelete line
CTL+W = Search for %%string%%
CTL+\ = Search for %%string%% and replace with $$string$$
CTL+C = Show line numbers

More info = http://en.wikipedia.org/wiki/Nano_(text_editor)


Now make the script executeable

chmod 0755 /root/scripts/restart-dspace

Manual Restart

Now run the script when needed by typing:

sudo -i
/root/scripts/restart-dspace

You can watch the restart by typing:

tail -f /var/log/tomcat7/catalina.out

To quit tailing the log file, type: CTL+c

Automatic Restart

To automatically and regularly restart, add a root user cron job.

As the "root" user user type the following:

crontab -e

Copy and paste the following to the bottom of the file and then save the file:

45 7 * * *    /root/scripts/restart-dspace

This will restart DSpace 07:45 in the morning each day.