LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-28-2011, 03:08 PM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
/etc/cron.daily/webalizer not running?


My webalizer cron job is not running. I can easily run it manually:
Code:
$ sudo /etc/cron.daily/webalizer
5816807 records (2110442 ignored, 3246 bad) in 3045.50 seconds, 1909/sec
250033 records (108 bad) in 236.00 seconds, 1059/sec
The cron job is sitting right there in the cron.daily directory, but it never seems to run. What the heck? I do not receive any emails about success, failure, or even an attempt. I know for a fact that the logs are not processed because the destination directory (/var/www/webalizer) is untouched.

I'm much more familiar with traditional crontab stuff than the cron.daily directory. If anyone could help me sort this out, I'd be most grateful.
 
Old 08-28-2011, 03:11 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
As a quick sanity check, ensure that it's root owned, writable only by root, and readable/executable for everyone else.

Code:
# chown root:root /etc/cron.daily/webalizer
Code:
# chmod 755 /etc/cron.daily/webalizer
-------

edit: Also confirm that the cron.daily scripts are actually being run from /etc/crontab. (They should be, unless someone was tinkering with it.)

Last edited by anomie; 08-28-2011 at 03:13 PM.
 
1 members found this post helpful.
Old 08-28-2011, 03:29 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Yes I had the sense to check that before:
Code:
~$ ls -l /etc/cron.daily/webalizer
-rwxr-xr-x 1 root root 1450 2009-11-11 13:45 /etc/cron.daily/webalizer
The /etc/crontab file does indeed look like it's trying to run the cron jobs. The logrotate cron certainly works as the logs all get rotated properly.
Code:
~$ sudo cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
 
Old 08-28-2011, 03:47 PM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Seems to me cron doesn't find the file.
Try to give the whole path to webalizer.
You can create a script.

Kind regards
 
Old 08-28-2011, 03:55 PM   #5
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Quote:
Originally Posted by repo View Post
Seems to me cron doesn't find the file.
Try to give the whole path to webalizer.
You can create a script.Kind regards
I'm not sure what you mean, repo. The basic webalizer script (/etc/cron.daily/webalizer) should in fact be found by the primary cron job on the server because it lives in /etc/cron.daily. The other cron jobs there appear to run just fine.

As described in my OP, if I run the command /etc/cron.daily/webalizer manually on the command line, it runs just fine.

If you look inside the file /etc/cron.daily/webalizer, this is what you see:
Code:
$ sudo cat /etc/cron.daily/webalizer
#!/bin/sh
# /etc/cron.daily/webalizer: Webalizer daily maintenance script
# This script was originally written by
# Remco van de Meent
# and now, all rewrited by Jose Carlos Medeiros

# This script just run webalizer agains all .conf files in /etc/webalizer directory

WEBALIZER=/usr/bin/webalizer
WEBALIZER_CONFDIR=/etc/webalizer

[ -x ${WEBALIZER} ] || exit 0;
[ -d ${WEBALIZER_CONFDIR} ] || exit 0;

for i in ${WEBALIZER_CONFDIR}/*.conf; do
  # run agains a rotated or normal logfile
  LOGFILE=`awk '$1 ~ /^LogFile$/ {print $2}' $i`;

  # empty ?
  [ -s "${LOGFILE}" ] || continue;
  # readable ?
  [ -r "${LOGFILE}" ] || continue;

  # there was a output ?
  OUTDIR=`awk '$1 ~ /^OutputDir$/ {print $2}' $i`;
  #  exists something ?
  [ "${OUTDIR}" != "" ] || continue;
  # its a directory ?
  [ -d ${OUTDIR} ] || continue;
  # its writable ?
  [ -w ${OUTDIR} ] || continue;

  # Run Really quietly, exit with status code if !0
  ${WEBALIZER} -c ${i} -Q || continue;
  RET=$?;

  # Non rotated log file
  NLOGFILE=`awk '$1 ~ /^LogFile$/ {gsub(/\.[0-9]+(\.gz)?/,""); print $2}' $i`;

  # check current log, if last log is a rotated logfile
  if [ "${LOGFILE}" != "${NLOGFILE}" ]; then
    # empty ?
    [ -s "${NLOGFILE}" ] || continue;
    # readable ?
    [ -r "${NLOGFILE}" ] || continue;

    ${WEBALIZER} -c ${i} -Q ${NLOGFILE};
    RET=$?;
  fi;
done;

# exit with webalizer's exit code
exit $RET;
Where should I "give the whole path to webalizer" or "create a script" ?
 
Old 08-28-2011, 04:04 PM   #6
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Cron has a limited path.
But since the path is set in the script it should work.

Kind regards
 
Old 08-28-2011, 04:58 PM   #7
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Quote:
Originally Posted by repo View Post
But since the path is set in the script it should work.
And yet it does not. I've tried reading the man pages for cron. I don't fully understand when the cron.daily jobs get run. The man page says that the cron job should result in output to the syslog but I see no mention of the word 'webalizer' in the syslog. I do, however see this line from yesterday's syslog:
Code:
Aug 28 06:25:01 ip-10-64-70-28 CRON[15213]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))
Is there some way that I might get a notification when webalizer runs? The cron man page mentions a MAILTO value that can be set but I'm not sure which file to set this in.
 
Old 08-28-2011, 05:26 PM   #8
Tenaka18
LQ Newbie
 
Registered: Jun 2011
Posts: 3

Rep: Reputation: Disabled
Quote:
Originally Posted by sneakyimp View Post
And yet it does not. I've tried reading the man pages for cron. I don't fully understand when the cron.daily jobs get run. The man page says that the cron job should result in output to the syslog but I see no mention of the word 'webalizer' in the syslog. I do, however see this line from yesterday's syslog:
Code:
Aug 28 06:25:01 ip-10-64-70-28 CRON[15213]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))
Is there some way that I might get a notification when webalizer runs? The cron man page mentions a MAILTO value that can be set but I'm not sure which file to set this in.
hi
cron.daily run at 6:25 every day

Code:
# m h dom mon dow user  command
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
hope it help
 
1 members found this post helpful.
Old 08-28-2011, 05:31 PM   #9
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Thanks Tenaka18. I'm still stumped here as to why it doesn't accomplish anything. I can run the command manually and it works just fine:
Code:
$ sudo /etc/cron.daily/webalizer
5816807 records (2110442 ignored, 3246 bad) in 3045.50 seconds, 1909/sec
250033 records (108 bad) in 236.00 seconds, 1059/sec
The other cron jobs in cron.daily seem to run. What the heck? I have no idea why it isn't running.
 
Old 08-28-2011, 10:48 PM   #10
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
He doesn't seem to be setting PATH in the script itself. It's set in /etc/crontab, but it's not exported to run-parts(8).

I recommend setting PATH explicitly in your script. When you run it from the command line, it has the benefit of your user's PATH.

If that doesn't work, then change the first line of your script to:
Code:
#!/bin/sh -x
so that we can see what this thing is doing.

-------

If you don't get any output from -x, then you have something else configured incorrectly (i.e. your MTA).
 
1 members found this post helpful.
Old 08-29-2011, 12:39 PM   #11
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Thanks anomie. I'm guessing you mean for me to add the -x flag to the shebang in /etc/cron.daily/webalizer. I have made this change. Now I just have to wait 12 hours for it to run

As for the MTA, that is an excellent observation. I do in fact not deliver any mail at all locally on this machine as it's an Amazon EC2 instance. All mail destined for local user user_n should get mapped to user_n@mydomain.com, then sent to Amazon SES and from there to Google Apps where mail is hosted. I do get notifications from another script that runs in the root user's crontab file, but there's a chance that the notifications for cron.daily, cron.monthly, etc. are getting sent to some other user and I don't have a mailbox for that user. Is there any way I might find out where cron.daily notifications get sent? I'd be happy to check that.
 
Old 08-29-2011, 12:52 PM   #12
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
If MAILTO is defined in /etc/crontab, mail will be sent to that address. If it is not defined, mail will be sent to the user the cronjob is running as -- in this case, root. (See the crontab(5) manpages for more details on that.)

If you're not explicitly forwarding root's mail, then it would be worthwhile to log in as him and check with mail(1).
 
Old 08-29-2011, 02:17 PM   #13
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
MAILTO is not set in /etc/crontab. Every single job in that file runs as root, so email should be sent to "root", correct? Or is that "root@localhost" ? In either case, email should get through. These emails are forwarded by postfix to another email account to which I have access. I have not received any emails from the existing cron.daily, cron.monthly, or cron.hourly jobs, but I do receive daily an email from the root user's crontab file -- there's a notice generated by the script that I need to fix.

Is there some quick/easy way to check a lot file to see if any cron job notifications are getting lost? I know that the sender's address has caused problems in other situations.
 
Old 08-29-2011, 02:21 PM   #14
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
You can check your MTA's logs. And I would log in as root and check his mail(1).

I think the second line in your script (after the sh-bang line) should be something like:
Code:
/bin/touch /tmp/AHA-I-WAS-HERE
Eliminate MTA difficulties from the equation, and prove that cron(8) is at least doing his job.
 
1 members found this post helpful.
Old 09-01-2011, 02:17 PM   #15
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
I keep checking back but webalizer still doesn't seem to be running -- and I am not receiving any email about the job nor am I seeing the AHA-I-WAS-HERE file. Is there a chance the /tmp folder got cleaned up since the job ran? It's been about 12 hours.

I've checked the MTA's logs and I do see some messages bouncing, but given that the temp file is not being created, I'm starting to think that this cron job is not running at all.
 
  


Reply



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
cron - how to give priority to a task running in cron.daily? MeeLee Linux - Newbie 3 11-09-2010 08:41 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 06:37 PM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
daily email from 'webalizer' tradnbillies Linux - General 1 01-08-2006 02:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:46 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
Open Source Consulting | Domain Registration