In linux/ubuntu, db2 is automatically started when it is started. In Ubuntu, DB2 is automatically started when it is started. In other linux systems, the directory may be different.
Therefore, make some modifications to the directory path. 1. Create a file named startdb2 in the etc/init. d folder. 2. The content is: www.2cto.com #! /Bin/sh # script to start DB2 instance on bootup # DB2_HOME = "/home/lilax/sqllib" DB2_OWNER = "lilax" case "$1" in start) www.2cto.com echo-n "starting IBM db2" su-$ DB2_OWNER-c $ DB2_HOME/adm/db2start touch/var/lock/db2 echo "OK"; stop) echo-n "shutdown IBM db2" su-$ DB2_OWNER-c $ DB2_HOME/admin/db2stop rm-f/var/lock/db2 www.2cto.com echo "OK"; restart | reload) $0 stop $0 start; *) echo "u Sage: $0 start | stop | restart | reload "exit 1 esac exit 0 www.2cto.com 3. create this file under win and put it in/etc/init. d folder 4. switch to/etc/init on the console. run the vi startdb2 command in the d folder to open the file, delete unnecessary symbols, and save the file. (In fact, we should use vi to write this file. I used to write it in notepad in the window and upload it to linux. The result is incorrect. It seems that the file format is incorrect ). 5. grant permissions to files. Run chmod-R 777 startdb2 www.2cto.com 6./etc/init. d In the/etc/init. d directory and run./startdb2 start for debugging. 7. After successful debugging, add chkconfig -- add startdb2 8 to the service list. Run the reboot command to restart the server! Author's boiled water 03210425