# Rc.d scripts at startup



## Wolfi83 (Sep 10, 2011)

hi,

i want that a script are executed as daemon on a systemstart.
is that the only thing i have to do?

http://www.freebsd.org/doc/en_US.ISO8859-1/articles/rc-scripting/rcng-args.html


----------



## Wolfi83 (Sep 10, 2011)

So, i mean, i only want rc.d script thats starts a .sh e.g. 


```
#host myrcdscript start
```
 - starts the run.sh

```
#host myrcdscript stop
```
 - starts the stop.sh


----------



## aragon (Sep 10, 2011)

I suspect you're trying to do the wrong thing, but maybe daemon(8) will help you.


----------



## Wolfi83 (Sep 10, 2011)

I just want to do it this way also:
if i restart my system and the system is going up the system (rc.d) have to autostart execute a runup.sh
just like mysql but without a daemon just execute the runup.sh


----------



## DutchDaemon (Sep 11, 2011)

Simplest way is to start the script in /etc/rc.local or in root's crontab with the @reboot time.


----------



## Wolfi83 (Sep 11, 2011)

DutchDaemon said:
			
		

> Simplest way is to start the script in /etc/rc.local or in root's crontab with the @reboot time.



What i've to do for this @reboot? 
So what i have to edit


----------



## DutchDaemon (Sep 11, 2011)

crontab(5)


----------



## Wolfi83 (Sep 11, 2011)

DutchDaemon said:
			
		

> crontab(5)



so


```
@reboot	*	*	*	*   root	sh   /root/test.sh
```
 ?


----------



## DutchDaemon (Sep 11, 2011)

No, as the manual show, @reboot replaces the time fields (so all asterisks), which is logical when you think about it. And use [cmd=]crontab -e[/cmd] as the root user, don't edit /etc/crontab. Also make sure your shell script has full path names to all commands.


----------



## Wolfi83 (Sep 11, 2011)

DutchDaemon said:
			
		

> No, as the manual show, @reboot replaces the time fields (so all asterisks), which is logical when you think about it. And use [cmd=]crontab -e[/cmd] as the root user, don't edit /etc/crontab. Also make sure your shell script has full path names to all commands.



Is at possible any way that the crontab starts my shell 10 minutes after the system start?


----------



## wblock@ (Sep 11, 2011)

Wolfi83 said:
			
		

> Is at possible any way that the crontab starts my shell 10 minutes after the system start?



Have the script or crontab entry sleep 600 before doing anything.


----------



## DutchDaemon (Sep 11, 2011)

Yes, something like this is in root's crontab entirely possible:


```
@reboot     /bin/sleep 600 && some_script
```


----------

