How do I run a shell script in the background?

I have a very simple script (created as a test) and the contents are
Code:
#!/bin/sh

echo "test me" >> testme.txt

I want it to run in the background. I tried
Code:
#. /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! :)
 
Hi,

There is huge differences between run in background and
Code:
#. /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)
 
Use nohup() if you want to detach the process from its controlling terminal.
 
  • Thanks
Reactions: cuq
Back
Top