Girish K Girish K - 1 year ago 88
Bash Question

Shell scripting - Is it possible to execute .sh file in background

I have one

script. After running this particular file. It is showing list of deleted files. I want to execute this file in the background instead of showing on the shell on which I have run this command.

Please advise, is there any way to achieve that? Thanks.

Answer Source

Just run it as:

./ >/home/username/output.txt 2>&1 &

The & at the end sends the command to the background.

The >/home/username/output.txt 2>&1 sends standard error and standard output to output.txt.

To keep it running after you log out, change it to this:

nohup ./ >/home/username/output.txt 2>&1 &
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download