New logwatch module not working in cron

Rick Stevens ricks at nerd.com
Thu Jan 27 18:17:42 UTC 2011


On 01/27/2011 09:24 AM, Gordon Charrick wrote:
> I wrote a new logwatch module for vnstat and put it in
> /etc/logwatch/scripts/services. If I run logwatch from the command line,
> it works fine. When cron runs it, the vnstat module doesn't run. The
> module is extremely simple - all it does is run the vnstat command.
> There are no errors being reported. All I get is an empty begin/end
> section for vnstat in the email from logwatch.
>
> I know it's not selinux because I originally had problems with that and
> I fixed that with a local selinux module for vnstat. I also specifically
> have the full path to the vnstat command in the logwatch vnstat script.
>
> Anyone have any clues on fixing this?

Cron jobs do not have the standard path when they run.  Odds are the
module (or something it calls) can't be found on cron's limited
path.  This can be fixed by putting a

	PATH=$PATH:/path1[:/path2]

(where /path1, etc. are the paths you want to include in the search)
after the "#!/bin/bash" at the top of the /etc/cron.daily/0logwatch
file to expand the path that cron has.  That, or make sure you use an
absolute path (e.g. "/usr/bin/name-of-program") for each program you're
running in the crontab.
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, C2 Hosting          ricks at nerd.com -
- AIM/Skype: therps2        ICQ: 22643734            Yahoo: origrps2 -
-                                                                    -
-           Lottery: A tax on people who are bad at math.            -
----------------------------------------------------------------------


More information about the users mailing list