Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I recently experienced a logwatch issue that is fixed by running export DATE_MANIP=DM5. cron seems to forget this when I logout (presumably because it's not saved).

Where can I add this custom environment variable? Since I don't manage the code for logwatch, I don't want to necessarily add an export command inside the script that launches. I tried adding export DATE_MANIP=DM5 to /root/.bash_profile but that doesn't help when I'm not logged in.

CentOS 6.x

share|improve this question
add comment

2 Answers 2

Edit your /etc/cron.daily/0logwatch script, and add the export DATE_MANIP=DM5 before the logwatch call.

example:

#!/bin/sh

#Set logwatch location
LOGWATCH_SCRIPT="/usr/sbin/logwatch"
#Add options to this line. Most options should be defined in /etc/logwatch/conf/logwatch.conf,
#but some are only for the nightly cronrun such as --output mail and should be set here.
#Other options to consider might be "--format html" or "--encode base64", man logwatch for more details.
OPTIONS="--output mail"

# Fix Date::Manip issue
export DATE_MANIP=DM5

#Call logwatch
$LOGWATCH_SCRIPT $OPTIONS

exit 0
share|improve this answer
add comment

look into BASH_ENV http://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/

try checking out http://stackoverflow.com/questions/6063618/bash-env-or-sourcing-a-file-in-a-non-interactive-non-login-shell

share|improve this answer
    
That's not going to help: to set the DATE_MANIP environment variable, you'd need to set the BASH_ENV environment variable, which is the same problem. And even if you did set BASH_ENV, it would have no effect on an sh script. –  Gilles Mar 28 at 23:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.