Monday 10 September 2012

Run shellscript on Boot

Copy shellscript file to /etc/init.d/XYZ (XYZ is shellscript name)

vim /etc/init.d/XYZ and copy below two line on top of file
(Note: change value of 10 and 80 in below two lines to any random number it shoud not match with other file)

--------------------------------
#!/bin/sh
# chkconfig: 2345 10 80
--------------------------------
Then Execute below two commands:

1>chkconfig --add XYZ
2>chkconfig XYZ on



To check if added or not just execute below command
chkconfig --list | grep XYZ

Output :

XYZ 0:off 1:off 2:on 3:on 4:on 5:on 6:off 





If we wanted to turn XYZ off in run levels 3, 4, and 5, we'd use a command like this :

chkconfig --level 345 XYZ off

No comments:

Post a Comment