error piping nohup to /dev/null


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting error piping nohup to /dev/null
# 1  
Old 02-28-2006
error piping nohup to /dev/null

Hi,

I have a script as follows:

#!/bin/sh

nohup ./my_program >& /dev/null &

However, i get a "Generated or received a file descriptor number that is not valid" whenever I run it.

running the command up in prompt is ok though.

if i change the first line to #!/bin/csh
i get a then: then/endif not found.

Pardon my ignorance but I really can't solve this problem.

Can anyone kindly offer some advice?
# 2  
Old 03-01-2006
try getting rid of the first '&'.
# 3  
Old 03-01-2006
ScatterBrain is right - but you may want to send any errors to std err for inital debugging.

try:

Code:
#!/bin/sh

nohup ./my_program > error.log 2>&1

# 4  
Old 03-01-2006
...or how about...

nohup ./my_program >/dev/null 2>error.log &

that is, if you don't care about standard output... but just wanna see stderr messages.

if you intend to do this a lot... or permanently with this script, you may want to consider adding within the script something like this:

exec 1>/dev/null
exec 2>error.log (or exec 2>&1 if you want no output at all)
# 5  
Old 03-02-2006
Thanks!

Thanks! U guys are great! I removed the first & and it really works.
I'm still baffled why including the first & will work in the command prompt but
not within the script though.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

2>/dev/null

Friends have the following problem a search may not find anything which would correct example: ls -ltr *prueba.txt | nawk '{ print $9 }' > Procesar.dat 2>/dev/null When he finds nothing gives me the following error ls: prueba.txt: No such file or directory because 2> / dev / null... (4 Replies)
Discussion started by: tricampeon81
4 Replies

2. UNIX for Dummies Questions & Answers

Redirect Standard Error to /dev/null is not working.

Hello. When I run a .ksh that contains the command below, and there is no file available in the source location the "FILE_NAME_*.CSV not found" error is still being displayed. FILEN=$(ssh ${SOURCE_SERV} "cd ${SOURCE_LOCATION} ;ls ${FILES}") 2> /dev/null. This is interfering with the rest... (4 Replies)
Discussion started by: jimbojames
4 Replies

3. UNIX for Dummies Questions & Answers

Eliminate error message (/dev/null)?

I am trying to eliminate an error message from a script. This is the error message: find: stat() error /usr/openv/netbackup/db/images/KUMAX: No such file or directory if ]; then runthiscommand=`su nxadm -c "ssh -t $new3 exec /bin/sh -s">/tmp/filew3 2>/tmp/error.txt<<EOF ... (1 Reply)
Discussion started by: newbie2010
1 Replies

4. Shell Programming and Scripting

Redirecting standard out to /dev/null goes to file "/dev/null" instead

I apologize if this question has been answered else where or is too elementary. I ran across a KSH script (long unimportant story) that does this: if ; then CAS_SRC_LOG="/var/log/cas_src.log 2>&1" else CAS_SRC_LOG="/dev/null 2>&1" fithen does this: /usr/bin/echo "heartbeat:... (5 Replies)
Discussion started by: jbmorrisonjr
5 Replies

5. HP-UX

/dev/Null error

Hi Guru's, I am trying to test the network speed or load by this command. but getting error " Not Connected ". Could you guys please help. ftp> put "|dd if=/dev/zero bs=8k count=1000000" /dev/null Not connected. Please use code tags! (9 Replies)
Discussion started by: sris.sun
9 Replies

6. UNIX for Dummies Questions & Answers

/dev/null 2>&1 Versus /dev/null 2>1

How are these two different? They both prevent output and error from being displayed. I don't see the use of the "&" echo "hello" > /dev/null 2>&1 echo "hello" > /dev/null 2>1 (3 Replies)
Discussion started by: glev2005
3 Replies

7. Shell Programming and Scripting

Error output of cat to /dev/null

Hello, I'm trying to send the error output of a 'cat' operation to /dev/null like this: cat /dirA/dirB/temp*.log > /dirA/dirB/final.log 2>/dev/null This works perfectly in a terminal, but not when placed in a script. If there are no files matching temp*.log the script outputs an error... (7 Replies)
Discussion started by: Nils88
7 Replies

8. AIX

Piping to /dev/rmt0 tape ?

I am trying to find a way to do the following on an AIX 4.2 with Korn: tar cvfpdl - . | compress > /dev/rmt0 The /dev/rmt0 is the device we use when we tar directly to it. I want to compress a folder's content to tape. Our current TAR does not have compression at all. We only have... (5 Replies)
Discussion started by: Browser_ice
5 Replies

9. Solaris

What is /dev/tty /dev/null and /dev/console

Hi, Anyone can help My solaris 8 system has the following /dev/null , /dev/tty and /dev/console All permission are lrwxrwxrwx Can this be change to a non-world write ?? any impact ?? (12 Replies)
Discussion started by: civic2005
12 Replies

10. UNIX for Dummies Questions & Answers

>/dev/null

Maybe it's an stupid question but remeber... I'm Junior.. I use command line to run programs, and some of them gives a lot of information when, for example, you open a window or other actions. That's really bad because my terminal gets full of unwanted messages, so I use "bin file & >/dev/null"... (1 Reply)
Discussion started by: piltrafa
1 Replies
Login or Register to Ask a Question