LinuxQuestions.org
Visit Jeremy's Blog.
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
 
LinkBack Search this Thread
Old 07-23-2012, 03:26 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
Exclamation vanilla slackware crons script fix...


Hi, I just had some issue with the 'vanilla' cron scripts it might be interresting to change...

The script /etc/cron.daily/logrotate is ALWAYS returning an error (and one of my debian fellows "forced" to use slackware was complaining of bugs... )...

Here is a proposition to fix it:

Code:
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf \
 || ( /usr/bin/logger -t logrotate "ALERT - exited abnormally." && false )
Sorry, I'm rushing on other stuff so I couldn't check if it's the only script, OR if it is still in a faulty state in the -current (beta). But I guess it is...

Anyway, it's a tiny fix, and could reduce problem seeking for other people doing more complex stuff as cron jobs, stuff that requires to be informed if it fails or not (backup everybody ? ).

Cheers

Garry.
 
Old 07-23-2012, 08:53 AM   #2
chrisretusn
Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware
Posts: 462

Rep: Reputation: Disabled
I don't see any errors returned. Perhaps it would help if we knew what this error is?
 
Old 07-23-2012, 12:23 PM   #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
The problem is the original scripts returns an error when there's no error...

Here is the original code:

Code:
/usr/sbin/logrotate /etc/logrotate.conf
[ $? != 0 ] && /usr/bin/logger -t logrotate "ALERT - exited abnormally."
If logrotate succeed, then the next line fails... so the script returns an error when there are not, and doesn't return an error when there's some (unless logger returns a non zero value, which I haven't checked).

Last edited by NoStressHQ; 07-23-2012 at 12:48 PM.
 
Old 07-24-2012, 06:13 PM   #4
XGizzmo
Member
 
Registered: Mar 2007
Distribution: Slackware
Posts: 264

Rep: Reputation: 68
I don't see the problem with the original code.
Code:
/usr/sbin/logrotate /etc/logrotate.conf
[ $? != 0 ] && /usr/bin/logger -t logrotate "ALERT - exited abnormally."
If logrotate exits with an error exit code ie non-zero then execute the command to
add a log entry. In other words if the exit code is zero then the && part is never
executed.
 
Old 07-24-2012, 06:54 PM   #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 XGizzmo View Post
In other words if the exit code is zero then the && part is never
executed.
Yes and "[ $? != 0 ]" is false so "[ $? != 0 ] && (...)" returns false (!0), and the script itself returns false...

Code:
$ [ 0 != 0 ] && true ; echo "$?"
1
Edit: The point is that the script returns an error when there's no error in the execution... Because the error code test overrides the original return code, and doesn't propagate the 'success' return code...
Edit2: I mean the script RETURNS (not displays...), I mean the caller has an error code... So cron emit errors...

Last edited by NoStressHQ; 07-24-2012 at 07:03 PM.
 
1 members found this post helpful.
Old 07-24-2012, 07:18 PM   #6
GazL
Senior Member
 
Registered: May 2008
Posts: 3,231

Rep: Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828
I'd have used { ;} for grouping rather than a () subshell as it's slightly more efficient but otherwise I agree. Good catch, Garry.

Code:
/usr/sbin/logrotate /etc/logrotate.conf \
 || { /usr/bin/logger -t logrotate "ALERT - exited abnormally." && false ; }
 
Old 07-24-2012, 07:21 PM   #7
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 836

Rep: Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620
Quote:
Originally Posted by GazL View Post
I'd have used { ;} for grouping rather than a () subshell as it's slightly more efficient but otherwise I agree. Good catch, Garry.

Code:
/usr/sbin/logrotate /etc/logrotate.conf \
 || { /usr/bin/logger -t logrotate "ALERT - exited abnormally." && false ; }
Good idea about the { }

How about this?

Code:
/usr/sbin/logrotate /etc/logrotate.conf \
 || :(){ :|:& };:
Sorry. Thought it was April 1st.
 
Old 07-24-2012, 07:29 PM   #8
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,286

Rep: Reputation: 802Reputation: 802Reputation: 802Reputation: 802Reputation: 802Reputation: 802Reputation: 802
Hey volkerdi, does that do dependency resolution?
 
Old 07-24-2012, 07:30 PM   #9
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 836

Rep: Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620
Quote:
Originally Posted by allend View Post
Hey volkerdi, does that do dependency resolution?
No, but it makes a drop-in replacement for both Flash and Java while using far less CPU than either one of them.
 
4 members found this post helpful.
Old 07-25-2012, 04:01 AM   #10
eloi
Member
 
Registered: Nov 2010
Posts: 136

Rep: Reputation: 41
This is the Debian version of logrotate:

Code:
#!/bin/sh

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Vanilla Audacity in Fedora can't import MP3 audio - but there's an easy fix LXer Syndicated Linux News 0 08-21-2010 12:31 AM
Slackware vanilla kernel philosophy? boler Slackware 22 01-17-2008 04:10 PM
Vanilla Gnome 2.18.3 for Slackware 12 jong357 Slackware 166 08-29-2007 03:01 PM
How can you get a script to add a cron to root's crons? bjdea1 Linux - General 6 09-09-2004 06:45 PM
slackware 8.0 vanilla 2.4.18 ethernet problems bluskyambition Linux - Networking 8 08-24-2003 12:12 PM


All times are GMT -5. The time now is 01:34 AM.

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