Results 1 to 5 of 5

Thread: [RESOLVED] Webalizer & Cronjobs

  1. #1
    Join Date
    Jan 2009

    resolved [RESOLVED] Webalizer & Cronjobs

    I have webalizer2.0 installed.

    I tried setting up a cronjob that ran once an hour but all I get is an email tlling me that the job failed.

    Webalizer :-
    Running the Webalizer

    The Webalizer was designed to be run from a Unix command line prompt or
    as a cron job. There are several command line options which will modify
    the results it produces, and configuration files can be used as well.
    Errrrmmmm.... I would disagree at this point on the claim that it runs as a cron job. The cronjob was set and reports a success in setting the job but all I get is an email with the error:-

    Died at /home/sites/{****.***.**}/public_html/stats/index.cgi line 15.

    and looking at the index.cgi script line 15 says :-
    this is par of a conditional
    if($cwd=~m#^(/home/(?:sites|cluster-sites/\d+)/[\w\.\-]+/)#) {
    } else {
    So I assume that the cronjob is failing because of this conditional.

    Any ideas on how to get this webalizer running as the help, FAQ's and help site do not cover this. Going to the help forum, it does not exist. The other help is on a yahoo groups page which I have not heard anything from in a few days.

    The full CGI is
    #!/usr/bin/perl -w
    use strict;
    use BSD::Resource;
    setrlimit(RLIMIT_AS, 128000000, 1280000000);
    setrlimit(RLIMIT_CPU, 120, 120);
    use CGI;
    use Cwd 'getcwd';
    use IO::Handle;
    my $cwd=getcwd();
    my $root_path;
    if($cwd=~m#^(/home/(?:sites|cluster-sites/\d+)/[\w\.\-]+/)#) {
    } else {
    my $cgi=new CGI;
    %ENV=(PATH=>'/bin:/usr/bin:/usr/local/bin', HTTP_HOST=>$ENV{HTTP_HOST});
    my $pid=open(CHILD, "-|");
    die unless defined $pid;
    if(!$pid) {
    	# child
    	# Get the mtime of webalizer.current for later...
    	my $current_mtime;
    	my @cstat=stat("webalizer.current");
    	if(@cstat) {
    	} else {
    	my %files;
    	my @poss_files=<$root_path/logs/*-access_log{,.*}>;
    	for my $poss_file (@poss_files) {
    		my $sort_fn=join "", reverse split(//, $poss_file);
    		$sort_fn=~s/^(zg|2zb)\.//; # Ignore compression stuff
    		$sort_fn=~s/^(\D)/0.$1/; # Make sure all are numbered.
    		# Use timestamp for emergency sort order
    		my @stat=stat($poss_file);
    		next unless @stat;
    		# Don't bother looking at obviously-unchanged files
    		next if $stat[9]<$current_mtime;
    	# We want high-numbered ones first
    	for(reverse sort keys %files) {
    		system("webalizer","-D", "dns.cache","-n", $ENV{HTTP_HOST}, $files{$_});
    	exit 0;
    local $/=undef;
    my $data=<CHILD>;
    close CHILD;
    if($data) {
    	print STDERR $data;
    print $cgi->redirect("index.html");
    What would I need to do to stop this CGI from stopping at line 15.

    The webalizer is a one click install through the web host CP, I have no access to the routine other than the web interface. As this routine is running every hour as asked, it would be the index.cgi thats the issue.

    Any ideas?

  2. #2
    Join Date
    Jan 2009
    Well I found a yahoo egroup for webalizer, posted my problem and now have my answer direct from the author who replied on his personal account but not via the web forum... suspect, very suspect:-
    Re: [webalizer] Need to cronjob the webalizer
    Tuesday, 7 April, 2009 1:06 AM
    From: "Bradford L. Barrett" <brad@mrunix.net>
    To: "Mark" <**********@yahoo.co.uk>

    This really has nothing to do with the Webalizer.

    On Mon, 6 Apr 2009, Mark wrote:
    Some help eh! What is it with rubberwalling people? Its not as if I went in to the forum and slated the software, I pointed out the issue which simply is this....

    A HTTP request results in the expected display of webstats.

    The Cronjob request which is server-side results in an email that states that the process died on line 15.

    Now you do not need to be a rocket scientist to work out that the cronjob is running and that the webalizer is the problem.

    The problem IMHO like most programming, lacks forethought to the end user and assumes too much in the way of you have 100% access to the commandline.

    For obvious security reasons the host does not allow direct commandline access but uses the extencp to help configure various requirements on the server.

    Anyone here know how to read and write PERL regular expressions, as I feel that this is where the issue is and why it is resulting in a "die" at the conditional here:-
    if($cwd=~m#^(/home/(?:sites|cluster-sites/\d+)/[\w\.\-]+/)#) {
    } else {
    So any webalizer users who know PERL, got any ideas?

  3. #3
    Join Date
    Jun 2003
    Looks to be testing if $cwd is a path starting /home/ then one of bits in brackets(not sure what the ? means at the start...) where \d+ means any number of digits(eg 1 or 00950 but not 1.4), followed by any combo of word characters, full stops or hyphens, ending with a /
    Then if it does match it assigns this path up to and including the / in $root_path.

    Is there any way you can output $cwd so you can manually check it(output to file maybe)?
    If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
    The same applies to HTML and the forums [HTML][/HTML] tags.

  4. #4
    Join Date
    Jan 2009
    I don't know to be honest as this appears to be an issue that only allows a http request.

    My web host has suggested some method, I went to look and couldn't find the "tool" they were refering to.

    I tried what they suggested and no have the index.cgi in the cronjob path but this ended in an email saying
    nice: /home/sites/{****.***.**}/public_html/stats/: Permission denied
    TBH, I am surprised at webalizer, regardless of the fact its free software, it seriously lack what I call credible support. I have had more support from my web host and from here than from Mr Unix as he calls himself.

    I shall try your suggestion of obtaining the $cwd string, which should be /home/sites/{****.***.**}/public_html/stats/ and see what is happening.

    If someone knows how to hard code this so it is not relying on being a dynamic script, it may prove to he a better option and solve the issue.

    I did ask the host if they could instal the PECL libray to add the http_get and http_request functions to make a http request but I think theyre not up for it and stated that the firewall prohibits http requests on the same machine. I guess this is to stop people from abusing the function.

    It is a head scratcher though, ho it works perfectly fine via an external http request but not from a server-cronjob and especially when the author claims runs as a cron job... I guess the author never bothered to read my post or comprehend it.

    Thanks for your reply.

  5. #5
    Join Date
    Jan 2009


    Ok, to anyone who is curious...

    It is here for those who have hosts with similar setups, as each server and host has different operational requirements and policy, it is best to ask your host. But here is the method used to get around the problem.

    "Shell script"

    In a text editor put in the code and save as update.sh for example
    #! /bin/bash
    cd /home/sites/domain.com/public_html/stats
    /usr/bin/webalizer -D dns.cache -nlocalhost -p -o . /home/sites/domain.com/logs/domain.com-access_log*
    and domain.com is the account domain of the account.

    this gets uploaded to your home folder (thats the folder that is 'domain.com' where public_html is visible) then chmod this update.sh to 755 which makes it executable by using an FTP client like filezilla or use PHP and write a script using the chmod() function, note that the correct way to use 755 in chmod is 0755 the 0 (leading zero) indicates octal, your path should be the whole path to the file your chmod-ing.

    When the file reads as an executable file, you set a cronjob routine to run the file you uploaded. This depends upon your setup or if you have a controlpanel that has it, the required settings to suit your needs. This automation removes the need to manually call the script to bring your stats update. The process is set to an hourly call to limit the work.

    Well it has proved to be an intresting journey...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12179 seconds
  • Memory Usage 2,887KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (5)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates