How to add script in Linux start-up

To add the scripts in start-up, we can use any of the one following command.
In the below scenario, say you wanted add mongod start/stop/restart script to Linux ( reboot/start-up)
 
[root@12d4-dl585-03 init.d]# chkconfig --add mongod
[root@12d4-dl585-03 init.d]#
 
(OR)
 
Add a line in the /etc/rc.local as below.
 
[root@12d4-dl585-03 init.d]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
 
touch /var/lock/subsys/local
/etc/init.d/mongod start
[root@12d4-dl585-03 init.d]#

  • Ask Question