1

I've a script like this:

/root/bin/script1.sh

putting this line inside .bashrc

/root/bin/script1.sh &

script1.sh does not run - the problem is &. Without "&" the script run perfectly

  • How can you tell it isn't running? – MadHatter supports Monica Nov 14 '15 at 9:48
  • Hello, script1.sh is a long process.. so using ps I can see if does run or not. – Pol Hallen Nov 14 '15 at 9:49
  • And is it happy to run in the background normally (ie, from the shell)? – MadHatter supports Monica Nov 14 '15 at 9:49
  • sure: I've already tested it obviously – Pol Hallen Nov 14 '15 at 9:52
  • 2
    Why do you want to put "a long process" into ~/.bashrc of all things? This gets loaded with every connection... – Sven Nov 14 '15 at 9:55
5

command tested:

/root/bin/script1.sh & disown

(this line inside .bashrc)

  • doc for disown in man bash – Skaperen Nov 14 '15 at 10:25
2

Try putting this into your .bashrc:

( /root/bin/script1.sh & )

This will execute your script inside a subshell.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.