Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed vnstats to see bandwidth statistics, I copied an init.d file tempalte, I placed it in init.d directory, it works ok to access this file and do start/restart/status, but this file should start automatically on system boot, correct? It doesn't start, how can I debug this? If after system boot I do init.d/vnstat then it starts.

I am running Centos 5

Thank you.

share|improve this question
most topics mention chkconfig but: "chkconfig: command not found" maybe there is another way ?! – adrianTNT Jan 6 '12 at 23:06
Obvious question, have you got chkconfig package installed? Is it in your $PATH environment variable? If you're desperate you can always drop it in rc.local,… else setup symlinks manually but obviously chkconfig is the more 'proper way' of doing things. – dtbnguyen Jan 6 '12 at 23:17
Found it installed in /sbin/chkconfig , thanks. – adrianTNT Jan 7 '12 at 10:00
up vote 4 down vote accepted

If you write an init script with the correct syntax, you can turn it into a service:

chkconfig --add vnstats

after that, you can turn it on or off for certain runlevels:

chkconfig --level 345 vnstats on

You can also manually start or stop services with the service command, using the functions declared in the script itself. For example, if your script has a function called stop and one called start, you can use

service vnstats stop and service vnstats start

Suggested reading: the official documentation

share|improve this answer
bash: chkconfig: command not found. Should the files in init.d start automatically? Is there another way ? – adrianTNT Jan 6 '12 at 23:04
I would expect it to be installed by default, what is the result of running yum info chkconfig – becomingwisest Jan 7 '12 at 0:41
Yum said chkconfig WAS installed, so I found it in /sbin/chkconfig and I had to use full path when calling the above instructions: /sbin/chkconfig --add vnstat – adrianTNT Jan 7 '12 at 9:59
I have a question tough. Even before the chkconfig --add I seen the service "vnstatd" stopped with --status-all, I am not sure if the -add command should contain vnstat or vnstatd, should it match the file name inside /etc/init.d/ folder? I added it with "--add vnstat" and the service status refers to it as "vnstatd". Thanks. – adrianTNT Jan 7 '12 at 10:02

If the init.d has a chkconfig setting, they you can chkconfig --add vnstat; chkconfig vnstat on

share|improve this answer

You should really follow earlier suggestions of adding a chkconfig section to your initfile, but if you're lazy and want to work around this, you can just symlink the file yourself like this:

ln -s /etc/init.d/vnstat /etc/rc3.d/S90vnstat

If you want to pursue the chkconfig path and lack the chkconfig package, install it with: yum install chkconfig

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.