2

I want to start a long-running process from a script that then exits, but I'm getting nowhere. Here's my most simple test. With each run, the console is blocked for 5 seconds.

// Create script
me@mine:~/workspace/bin$ cat > test.sh
sleep 5
// Verify script
me@mine:~/workspace/bin$ cat test.sh
sleep 5
// Make executable
me@mine:~/workspace/bin$ chmod 777 test.sh
// Expect to wait
me@mine:~/workspace/bin$ ./test.sh
// Expect to return, still waits
me@mine:~/workspace/bin$ ./test.sh ?
// Ditto
me@mine:~/workspace/bin$ nohup ./test.sh ?
nohup: ignoring input and appending output to 'nohup.out'
me@mine:~/workspace/bin$ 

I'm running Ubuntu 17.04 64, GNU bash, version 4.4.7(1)-release (x86_64-pc-linux-gnu)

I'm a Linux noob, and I'm sure I'm not getting something. Any help is appreciated.

Steve11235
  • 2,849
  • 1
  • 17
  • 18

3 Answers3

2

Use ampersand: nohup ./test.sh &

phd
  • 82,685
  • 13
  • 120
  • 165
0

Looks like your script is waiting for something. Paste your script in here.

  • How is that different from the `chomd` then execute in the original question, and how will that put `test.sh` in the background? – Eric Renouf Jun 09 '17 at 13:55
0

There are a couple ways to do it, my go-to way is by put an ampersand & at the end of the line.

More ways are found with this answer

More explanation on the ampersand method here

ibstevieb123
  • 96
  • 10