Skip to main content

Run scripts before domlog rotates

Comments

7 comments

  • JeffElkins
    Still no joy with this issue. As far as I can tell, the logrotate.conf does not control the daily rotation of the apache2/domlogs. Google has been zero help in solving this. Very frustrating, after hours of research.
    0
  • cPanelMichael
    Hello, The following option is available under the "Stats and Logs" tab in "WHM >> Tweak Settings": "Delete each domain"s access logs after statistics are gathered" Per it's description: This setting will force the system to delete all access logs after each run. Thus, you'd need to disable this option and rotate the Apache domlogs on your own, or setup a hook that runs your custom script "pre" log processing: Guide to Standardized Hooks - Software Development Kit - cPanel Documentation Guide to Standardized Hooks - Stats Functions - Software Development Kit - cPanel Documentation Thank you.
    0
  • JeffElkins
    Thank you.
    0
  • JeffElkins
    I tried the code below, it appeared to register properly: System: Stats: weight: 100 hook: MyStats::runscripts exectype: module stage: pre id: KrW3DbP2pUlaz99VVnx7KWNe However, calling the script (sub: runscripts) doesn't work. The script being called executes w/o issues manually. #!/usr/bin/perl # Package this module. package MyStats; # Return errors if Perl experiences problems. use strict; use warnings; # Use cPanel's error logging module. use Cpanel::Logger; # Instantiate the cPanel logging object. my $logger = Cpanel::Logger->new(); # Embed hook attributes alongside the action code. sub describe { my $hooks = [ { 'category' => 'System', 'event' => 'Stats', 'stage' => 'pre', 'hook' => 'MyStats::runscripts', 'exectype' => 'module', } ]; return $hooks; } sub runscripts { system("/bin/bash /usr/local/bin/dstats"); };
    0
  • cPanelMichael
    Hello, If you already have a script that works when you run it manually, you can simply add it to the hooks system using a command like this rather than setting up a separate custom script: /usr/local/cpanel/bin/manage_hooks add script /var/cpanel/myapp/myscript.sh --manual --category System --event Stats --stage pre
    Thank you.
    0
  • JeffElkins
    That seems simple enough, thanks! How do you delete a hook entered in this manner? I tried: bin/manage_hooks del script /usr/local/bin/myscript, but no joy.
    0
  • cPanelMichael
    How do you delete a hook entered in this manner? I tried: bin/manage_hooks del script /usr/local/bin/myscript, but no joy.

    You'd use a command like this: /usr/local/cpanel/bin/manage_hooks delete script /var/cpanel/myapp/myscript.sh --manual --category System --event Stats --stage pre
    Or, simply use "WHM Home " Development " Manage Hooks". We document this at: Guide to Standardized Hooks - The manage_hooks Utility - Software Development Kit - cPanel Documentation Thank you.
    0

Please sign in to leave a comment.