What's wrong with this go-script line?


Recommended Posts

It worked on my system.

Do you have end of line correct?

 

root@unraid /boot/bin #nohup nice /boot/bin/cached.sh >/dev/null 2>&1 </dev/null & 

[1] 8979

root@unraid /boot/bin #ps -f

UID        PID  PPID  C STIME TTY          TIME CMD

root      8973  8971  0 09:00 pts/0    00:00:00 -bash

root      8979  8973  0 09:02 pts/0    00:00:00 /bin/bash /boot/bin/cached.sh

root      8980  8979  0 09:02 pts/0    00:00:00 sleep 300

root      8981  8973  0 09:02 pts/0    00:00:00 ps -f

 

in my go script and my cached.sh test script I have the following as the first line.

#!/bin/bash

Link to comment

I thought this line wold launch cached.sh in the background and return to the command prompt but it doesn't....

 

nohup nice /boot/bin/cached.sh >/dev/null 2>&1 </dev/null &

 

Any ideas what is wrong ?

 

Here's a hint....

Question.   What command was run?

Answer:      nohup

 

Question: How was the command invoked?

Answer:   The "nohup" command was run in the background.   The "nohup" command had its standard input, output, and stderr connected to /dev/null.

 

The nohup then runs "nice" which in turn then runs "bash" that interprets the script.

 

Last question... how are you invoking this line?  Are you running it on the command line, or passing it through "fromdos" and then sending it to a "sh" process?

 

A lot has to do with which command is actually being put in the background with the "&"

 

A different approach (and one I just learned myself) might be:

nice cached.sh &

disown %1

 

Joe L.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.