# Are there ways to run rc.d scripts in the background?



## wafflesausage (Mar 1, 2012)

Hello, I've written an rc.d script that simply runs the portsnap program. However, the problem (as I've forseen it) is that I have to wait until the script finishes before handing control over to the user -- which is ridiculous considering that downloading a 60MB or so file may take minutes depending on the speed of your Internet connection. I was wondering if there are any ways to run this (or other scripts) in the background. Any ideas? Dirty hacks and workarounds accepted


----------



## phoenix (Mar 1, 2012)

Read the portsnap(8) man page, especially the section on using cron(1).  What you want to do is already supported, no need for a custom rc script.


----------



## gkontos (Mar 1, 2012)

Adding a & operator would also help.


----------



## wafflesausage (Mar 1, 2012)

When I add the & operator, it says that it shouldn't be run interactively and recommends running *portsnap cron* instead. However, running portsnap at boot really wasn't the point of the exercise -- what I'm really trying to do is run lengthy processes at boot from rc.d without having to wait for them to resolve to be able to use the console.


----------



## DutchDaemon (Mar 1, 2012)

You can always use @reboot in a crontab.


----------



## gkontos (Mar 1, 2012)

wafflesausage said:
			
		

> When I add the & operator, it says that it shouldn't be run interactively and recommends running *portsnap cron* instead. However, running portsnap at boot really wasn't the point of the exercise -- what I'm really trying to do is run lengthy processes at boot from rc.d without having to wait for them to resolve to be able to use the console.



Like phoenix told you portsnap(8)() already does what you want via a cron(1)() job.

For further help in rc.d scripting there is a lot of available information in FreeBSD docs:

Link: http://www.freebsd.org/doc/en/articles/rc-scripting/

Best Regards,


----------

