# How to exceute a shell script when FreeBSD start



## lastofme (Sep 12, 2014)

Hi guys, I have been looking for information on the forums to execute a shell script when FreeBSD starts or after a reboot, but I have not managed to do it. Can someone help with that? A link to another topic or a explain it a little.

Kind regards.


----------



## DutchDaemon (Sep 12, 2014)

A common method is to start a script using /etc/rc.local (does not exist by default) or using cron with the @reboot time. If you want to go more low-level. you can use a start script in /usr/local/etc/rc.d (look there for examples), using /etc/rc.conf for settings.


----------



## ondra_knezour (Sep 12, 2014)

And there is some documentation on this topic, as usual 
rc(8)
Practical rc.d scripting in BSD
Porters Handbook: Starting and stopping services


----------



## uzsolt (Sep 24, 2014)

lastofme said:
			
		

> Hi guys, I have been looking for information on the forums to execute a shell script when FreeBSD starts or after a reboot, but I have not managed to do it. Can someone help with that? A link to another topic or a explain it a little.


What type of script do you want execute? If it's a user-specified you can use ~/.profile, ~/.cshrc, ~/.login files.


----------



## Carpetsmoker (Oct 1, 2014)

Or, if it's for a desktop, the ~/.xinitrc (xinit, startx) or ~/.xsession (xdm, gdm, etc.) might be suitable.


----------

