LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-09-2008, 11:23 PM   #1
surfchen
LQ Newbie
 
Registered: Mar 2008
Posts: 3

Rep: Reputation: 0
stdout,stderr makes program crash


Environment:
debian 64bit,Dual-Core AMD Opteron(tm) Processor 2212,raid 5.

All examples run via crontab.(There is no problem if runs on a terminal).

The /usr/local/bin/xxx stands for many programme,not only one have this problem. And not all parameters append to xxx cause this problem.What I want to say is:Some programs in some cases have the problem I will show below.But I can't figure out what the case is.It seems that there is no same point among them.

This problem only appear on this 64-bit box.On other boxes I have,the problem is disappear..

#1:
b1,b2,b3 were created.There is no problem in this case.
Quote:
#!/bin/sh
touch /tmp/b1
/usr/local/bin/xxx
touch /tmp/b2
touch /tmp/b3
#2:
I added one line after the 2nd touch.In this case,just b1 and b2 were created.It seems like that this script is crashed during "echo abc".
Quote:
#!/bin/sh
touch /tmp/b1
/usr/local/bin/xxx
touch /tmp/b2
echo abc
touch /tmp/b3
#3:
I appended a stderr redirection to xxx.It works like the #1 that b1,b2 and b3 were all created.
Quote:
#!/bin/sh
touch /tmp/b1
/usr/local/bin/xxx 2>/tmp/out
touch /tmp/b2
echo abc
touch /tmp/b3
#4:
This time I appended a stdout redirection.It works like the #2 that just b1,b2 were created.
Quote:
#!/bin/sh
touch /tmp/b1
/usr/local/bin/xxx 1>/tmp/out
touch /tmp/b2
echo abc
touch /tmp/b3

Could anyone tell me what the problem is or how can I debug in this case?
 
Old 03-11-2008, 03:32 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Well, crontab runs detached, ie no connection to a terminal, so stdout/stderr have nowhere to go.
You should be re-directing them, either per cmd in your script, or outside:

/home/script.sh >my.log 2>&1

You'll prob find you or root has emails from the cron daemon if these problems arise.
 
Old 03-11-2008, 05:11 AM   #3
surfchen
LQ Newbie
 
Registered: Mar 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks, chrism01.

Yes,redirecting them will make all goes well. But on my other boxes,there is no problem even if I don't redirect stdout/stderr.

Why?
 
Old 03-11-2008, 06:27 AM   #4
surfchen
LQ Newbie
 
Registered: Mar 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Hey,all~

I solved this problem by installing exim4.

but if I add "MAILTO=" to crontab,problem appear again.

If nobody tell me what was going, I will look into the source code of crontab to get the detail.I have tried google,but I found nothing about these.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
send stderr to a file and also to stdout pranavchoudhary Linux - Newbie 7 08-25-2008 02:57 AM
Redirecting stdout, stderr to pty0? Rostfrei Linux - General 4 03-20-2007 04:15 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 03:36 AM
redirecting stdout and stderr to a file Avatar33 Programming 4 03-12-2005 08:55 AM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 07:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration