LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 07-26-2012, 04:39 AM   #1
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 271

Rep: Reputation: 87
[Cron jobs] More error reporting...


Hi,

Right now, the vanilla setup of crontab, prevents us to receive failure mail. Because:

- contrab is redirecting stdout to /dev/null
- run-parts is always emitting something and redirect stderr script channel into the stdout channel (so it goes into garbage).

We were able to fix all this with:
1) fixing /usr/bin/run-parts (see below).
2) removing the "1> /dev/null" from the cron tab.

run-parts original code:
Code:
  # If we've made it this far, then run the script if it's executable:
  if [ -x $SCRIPT ]; then
    echo "$SCRIPT:"
    echo
    $SCRIPT 2>&1
    echo
    ...
Our fix on run-parts:
Code:
  # If we've made it this far, then run the script if it's executable:
  if [ -x $SCRIPT ]; then
    $SCRIPT 2>&1 || echo "$SCRIPT failed."
    ...
I guess we even should be able to just do
Code:
$SCRIPT || echo "$SCRIPT failed." 1>&2
which seems to me as even better.


Everything run smoothly, the only mail we have are "errors". Note that we CAN receive mail if something outputs to stdout, but usually a good unix tool, run silently if no error, and if it verbose something, its better(/easy) just to redirect THAT call and not everything...

Of course part of the comment on top of crontab might be deprecated if those fix are applied .

Obviously, cron jobs scripts should have a normal behavior (we had to fix logrotate too, see this thread)...

Cheers

Garry.

Last edited by NoStressHQ; 07-26-2012 at 04:52 AM.
 
Old 07-26-2012, 06:57 AM   #2
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 271

Original Poster
Rep: Reputation: 87
Just to quote the comment on top of the cron tab:
Code:
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
I think all those fixes make this comment a bit deprecated, as there shouldn't be any "strange mail every 5 minutes" BUT the real error notification, and you WILL have the error notifications (instead of nothing).

That's all... Sorry, we're in delivery time here, it's hot, and didn't had the time (/mind) to pack all those in one post.

Cheers

Garry.
 
1 members found this post helpful.
Old 08-01-2012, 07:51 AM   #3
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 271

Original Poster
Rep: Reputation: 87
Sorry to bump this, but is it irrelevant ? Do I need to provide more information ? Does it introduce a risk of breaking something ? Anything ?

Cheers

Garry.
 
Old 08-01-2012, 01:08 PM   #4
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 3,039
Blog Entries: 4

Rep: Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734
and I thought it was just "me"...
The only 2 mails I have ever received are
Code:
sudo mail -u root
Heirloom mailx version 12.4 7/29/08.  Type ? for help.
"/var/spool/mail/root": 2 messages 2 unread
>U  1 To root            Thu Mar 10 23:33   53/1912  Register with the Linux counter project
 U  2 To root            Thu Mar 10 23:35  322/15427 Welcome to Linux (Slackware 13.37)!

15 day old system. Stock+KDE
Code:
    35      # If we've made it this far, then run the script if it's executable:
    36      if [ -x $SCRIPT ]; then
    37        echo "$SCRIPT:"
    38        echo
    39        $SCRIPT 2>&1
    40        echo
    41      fi
    42    done
I made the suggest change and sorta hoping it works.

Subscribed with Interest...

JJ
 
Old 08-02-2012, 06:57 AM   #5
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 271

Original Poster
Rep: Reputation: 87
Quote:
Originally Posted by Habitual View Post
and I thought it was just "me"...
Hehe, me too. Maybe I should have asked about automatic dependencies so I would have more reactions .

I might have chosen the title badly tho.

Hey Habitual, you have quite an interesting blog, a great snippet vault!

Cheers

Garry.
 
Old 08-02-2012, 07:15 AM   #6
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Slack14_64_Multilib
Posts: 3,039
Blog Entries: 4

Rep: Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734Reputation: 734
Quote:
Originally Posted by NoStressHQ View Post
...you have quite an interesting blog, a great snippet vault!

Cheers

Garry.
Thanks, it's just a place to store stuff so my brain can focus on learning more stuff.

Peace.

P.S. Tomorrow, I have another cron set to run at 8am EDT, so I'm hoping...

Any clues in the cron log(s)?
 
Old 08-02-2012, 08:34 AM   #7
NoStressHQ
Member
 
Registered: Apr 2010
Location: Lausanne - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware Leet - 32/64bit
Posts: 271

Original Poster
Rep: Reputation: 87
Quote:
Originally Posted by Habitual View Post
Any clues in the cron log(s)?
If you're asking me, we had to do those fix some time ago in order to have a proper setup for our automatic backup of our server, so we have no problem since then, when we had mails it was because of real failures/errors, rest of the time it's silent. And everything is working smoothly. Well technically, I'm sure we solve a problem and didn't introduced any, I mean we really know what we do, on the other hand, experience told me that "we never know" so I'm open to any report.

I just wish it could be integrated in stock slackware, as for my point of view it's a real fix of a real "bug"... (and it's more in the 'vanilla' philosophy of slackware than the existing code IMHO).
 
  


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
old jobs reporting in LSF ? sun_sun Linux - Networking 0 02-05-2008 12:25 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 06:37 PM
cron reporting errors with sendmail slybob Linux - Server 3 01-23-2007 07:12 AM
cron.daily reporting a squidGuard config problem kalahari875 Mandriva 3 10-03-2004 11:14 AM
CRON Jobs scottpioso Linux - Software 63 11-28-2003 06:45 PM


All times are GMT -5. The time now is 05:55 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration