1

how to run shell script in background in unix?

My script

#!/bin/sh
while [ true ]
do
    ps -fu $USER>>/home/axway/trace.log 2>&1 
    sleep 10
done

running above script (shellEx1.sh) in background by nohup command on promt

nohup ./shellEX1.sh &

having below isuue:

$ nohup ./shellEX1.sh &
[3] 19520
$ nohup: ignoring input and appending output to    `nohup.out'
1
  • What is the problem? The script should work. Nohup is just giving you a warning ... Commented Jul 17, 2014 at 7:22

2 Answers 2

1

Its warning to say like the output of the script will be written in file 'nohup.out'. In order to remove this warning, you can try

nohup ./shellEX1.sh >/tmp/output.txt &

or

nohup ./shellEX1.sh >/dev/null &
Sign up to request clarification or add additional context in comments.

Comments

0

Just a thought, you could make it connect or create a screen instance at the start.

screen -S bashscript my bash script

1 Comment

That's not at all what the OP is asking, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.