# Bandwidthd at startup question



## danaeckel (Mar 9, 2013)

I have a stupid question, for whatever reason I can't get bandwidthd to start at boot. I always have to start it manually. How do I get it to start at boot time?


----------



## cpm@ (Mar 9, 2013)

To start bandwidthd at boot time, use /usr/local/etc/rc.d/ directory as follows: 
	
	



```
# cp etc/rc.d/bandwidthd.sh.sample /usr/local/etc/rc.d/bandwidthd.sh
```

For more information, see http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/book.html#startup-config-files.


----------



## danaeckel (Mar 10, 2013)

Well, I tried that before I posted on the thread, and I tried it exactly how this reply went, and I get this error,


```
/etc/rc: WARNING: Ignoring old-style startup script /etc/rc.d/bandwidthd.sh
```

I have FreeBSD 9.1, and installed bandwidth from ports if that matters.

Dana


----------



## cpm@ (Mar 10, 2013)

danaeckel said:
			
		

> Well, I tried that before I posted on the thread, and I tried it exactly how this reply went, and I get this error,
> 
> 
> ```
> ...



In short, no keeping `.sh' suffix. See rc(8). 

Please, rename file:

```
# cd /usr/local/etc/rc.d/
# mv bandwidthd.sh bandwidthd
```

**EDIT**

Other possibility is create an rc.d script controlled with rc.conf(5) as follows:

```
#!/bin/sh
#
# PROVIDE: utility
# REQUIRE: DAEMON
# KEYWORD: shutdown

. /etc/rc.subr


name="bandwidthd"
rcvar=`set_rcvar`
command="/usr/local/bandwidthd/bandwidthd"

load_rc_config $name

utility_enable=${utility_enable-"NO"}
utility_pidfile=${utility_pidfile-"/var/run/utility.pid"}

pidfile="${utility_pidfile}"

run_rc_command "$1"
```

Add this line to /etc/rc.conf

```
bandwidthd_enable="YES"
```

Run to start without reboot: 
`# /usr/local/etc/rc.d/bandwidthd start`

I recommend you to read as reference document Practical rc.d scripting in BSD.


----------



## danaeckel (Mar 10, 2013)

Thank you. when I created the script and ran through rc.conf that worked perfectly. When I removed the .sh, that method gave me a prefix error.

Dana


----------



## cpm@ (Mar 10, 2013)

You are welcome. Have fun


----------

