# How do I run a shell script in the background?



## mrjayviper (Oct 2, 2012)

I have a very simple script (created as a test) and the contents are 
	
	



```
#!/bin/sh

echo "test me" >> testme.txt
```

I want it to run in the background. I tried 
	
	



```
#. /home/user-here/test.sh
```
 and it doesn't work. I'm getting a "command not found" error.

Any ideas on how to run scripts/commands in the background? 

Thanks!


----------



## akil (Oct 2, 2012)

Hi,

There is huge differences between run in background and 

```
#. /home/user-here/test.sh
```
which refers to applying settings to current environment.

If you would like to run script in background, please follow with below sugestion
`# ./home/user-here/test.sh &`

In case of returning to the script which is run in background
`# fg`

There is always chance to learn sh(1)


----------



## lme@ (Oct 2, 2012)

Use nohup() if you want to detach the process from its controlling terminal.


----------

