# Pentaho Installation Wizard or manual installation: Starting on boot

The installation wizard and manual installation do not provide a way to start the Pentaho Repository and Pentaho Server automatically on boot. They also do not stop automatically at shutdown. Here are examples of how you might approach creating a script to start at boot and stop at shutdown.

* This procedure assumes that you are running the Pentaho Server under the `pentaho` local user account. If you are using a different account to start these services, substitute it in the script in step 2.
* This script also assumes you are using the PostgreSQL repository. Where `postgresql` appears in this script, change it to reflect the RDBMS you are using as a repository, either MySQL or Oracle.
* This script was tested on Red Hat Enterprise Linux. You may have to modify the details of the script if you use a different distribution of Linux or other Unix-like operating system, different shells, or different init systems.

1. With root permissions, create a file in `/etc/init.d/` named `pentaho` or named `pdi`, depending on your needs.
2. Using a text editor, copy the following content into the new pentaho script. If running the solution repository on the same machine as the server, change `postgresql` to the name of the `init` script for your database.

   If running the solution repository on the a remote computer, remove `postgresql` entirely. You may also have to adjust the paths to the Pentaho Server scripts to match your situation.

   ```xml
   #!/bin/sh
   ### BEGIN INIT INFO
   # Provides: start-pentaho stop-pentaho
   # Required-Start: networking postgresql
   # Required-Stop: postgresql
   # Default-Start: 2 3 4 5
   # Default-Stop: 0 1 6
   # Description: Pentaho Server
   ### END INIT INFO

   case "$1" in
   "start")
   su - pentaho -c "/home/pentaho/pentaho/server/pentaho-server/start-pentaho.sh"
   ;;
   "stop")
   su - pentaho -c "/home/pentaho/pentaho/server/pentaho-server/stop-pentaho.sh"
   ;;
   *)
   echo "Usage: $0 { start | stop }"
   ;;
   esac
   exit 0
   ```
3. Save the file and close the text editor.
4. Open `/home/pentaho/pentaho/server/pentaho-server/start-pentaho.sh`.
5. Change the last `if` statement to match the this example:

   ```xml
   if [ "$?" = 0 ]; then
     cd "$DIR/tomcat/bin"
     export CATALINA_OPTS="-Xms4096m -Xmx6144m -XX:MaxPermSize=256m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
     env JAVA_HOME=$_PENTAHO_JAVA_HOME sh ./startup.sh
   fi
   ```
6. Save the file and close the text editor.
7. Make the init script executable.

   ```xml
   chmod +x /etc/init.d/pentaho
   ```
8. Add the `Pentahoinit` script to the standard run levels by using the `update-rc.d` command, so that it runs when the system starts, and stops when the system is shut down or rebooted.

   This command may not exist on your computer if it is not Debian-based. If that is the case, consult your distribution documentation or contact your distribution's support department to determine how to add init scripts to the default run levels.

   ```xml
   update-rc.d pentaho defaults
   ```
