WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Historical logs for IBM HTTP Server

saravana kumar

saravana kumarFri April 05, 2013 02:28 PM

  • 1.  Historical logs for IBM HTTP Server

    Posted Tue April 02, 2013 11:38 AM
    HI ALL

    I have defined logrotation for IBM HTTP Server in daily basis. the access.log and error.log are rotating everyday.


    But I want to keep only 30 historical logs without deleting like we have option in websphere.

    will it possible in IBM HTTP Server?

    Thank you


  • 2.  Historical logs for IBM HTTP Server

    Posted Tue April 02, 2013 12:54 PM
    Simple solution is to use the following in a cron job

    This will delete log files older than 7 days/ not modified in 7days from the specified directory
    find /Apache_logs_location -type f -mtime +7 -exec rm -v '{}' \;


  • 3.  Historical logs for IBM HTTP Server

    Posted Tue April 02, 2013 01:23 PM
    Thanks Joseph

    But my environment is in windows. Is there any way please let me know. Thank you


  • 4.  Historical logs for IBM HTTP Server

    Posted Wed April 03, 2013 12:14 PM
    joseph where should we want to execute this command under apache bin or other lcation find /Apache_logs_location -type f -mtime +7 -exec rm -v '{}' \;


  • 5.  Historical logs for IBM HTTP Server

    Posted Wed April 03, 2013 01:14 PM
    find /Apache_logs_location -type f -mtime +7 -exec rm -v '{}' \;
    Its a unix command  you can run from any directory in Unix/linux OS.

    But apache_logs_location is where your IBM HTTP Server installed

    example

    find /opt/IBM/HTTPServer/logs -type -f -mtime+7 -exec rm -v'{}' \;

    Thanks


  • 6.  Historical logs for IBM HTTP Server

    Posted Wed April 03, 2013 02:23 PM

    hai i am facing this error
    [root@localhost ~]# find /home/IBMIHS/logs -type -f -mtime +7 -exec rm -v'{}' \;
    find: Arguments to -type should contain only one letter
    [root@localhost ~]#



  • 7.  Historical logs for IBM HTTP Server

    Posted Wed April 03, 2013 03:44 PM
    its my typo mistake.

    try the below cmd once

    find /home/IBMIHS/logs -type f -mtime +7 -exec rm -v '{}' \;


    Thanks


  • 8.  Historical logs for IBM HTTP Server

    Posted Thu April 04, 2013 07:22 AM

    Hi, 

       Windows isn't too bad nowadays all the scripts you have for *nix you can get for Windows too.


      Create bat file and schedule in Windows Task Scheduler.
     
      To see what files are going to be deleted you can use echo.

      forfiles -p "C:\what\ever" -s -m *.* -d -NUMBER_OF_DAYS -c "cmd /c echo @file"
     
      Then delete....

      forfiles -p "C:\what\ever" -s -m *.* -d -NUMBER_OF_DAYS -c "cmd /c del @path"

       In Win7

      forfiles -p "C:\what\ever" -s -m *.* /D -NUMBER_OF_DAYS /C "cmd /c del @path"

      Source
       stackoverflow.com/questions/51054/batch-...

      Hope this helps.

    Regards


  • 9.  Historical logs for IBM HTTP Server

    Posted Thu April 04, 2013 12:04 PM
    thank you adminuppala,joseph the command you posted is working correctly.


  • 10.  Historical logs for IBM HTTP Server

    Posted Thu April 04, 2013 02:17 PM
    can we increase the size of error.log file and access.log file which is under IHS/logs using a command every at night 8pm.


  • 11.  Historical logs for IBM HTTP Server

    Posted Thu April 04, 2013 07:02 PM
    Sure saravana, but you need to restart the IHS.

    Do and script to change the values in http.conf and restart the server. Put the script in crontab and you have it.

    Regards


  • 12.  Historical logs for IBM HTTP Server

    Posted Thu April 04, 2013 11:21 PM
    Hai Gabriel "my question is can we increase size of error.log file and access.log file using command if possible can you send the command"


  • 13.  Historical logs for IBM HTTP Server

    Posted Fri April 05, 2013 05:47 AM
    Saravana

      There is no command of IHS, it need to be a operating system command (shell command).

      I guess you are using rotatelogs, if not, you can't stablish size of the logs in IHS.
     
      After the change you need to restart IHS so you need an script to change the value and then restart the IHS.
     
      I haven't the commmand but there are a lot of examples (google) to change value(word) in a file (httpd.conf)
     
    regards


  • 14.  Historical logs for IBM HTTP Server

    Posted Fri April 05, 2013 02:28 PM
    Thank you veryu much Gabriel.


  • 15.  Historical logs for IBM HTTP Server

    Posted Mon April 08, 2013 12:13 PM

    Summery of this thread



    List and Delete

    Unix/Linux

    List files that are older than 'n' days
    find path_to_logs_directory -type f -mtime +n -exec ls -l '{}' \;

    delete files that are older than 'n' days
    find path_to_logs_directory -type f -mtime +n -exec rm -v '{}' \;


    Windows
    List files that are older than 'n' days
    forfiles -p "path_to_logs_directory" -s -m *.* -d -n -c "cmd /c echo @file"

    delete files that are older than 'n' days
    forfiles -p "path_to_logs_directory" -s -m *.* -d -n -c "cmd /c del @path"


    Scheduling cleaning jobs
    - Unix/Linux
    you can use 'crontab' to schedule the above commands to run everyday/week etc... Check the following link for CRONTAB (websphereapplicationservernotes.wordpres...)

    -Windows
    Put the above delete command in a batch file (.bat)
    Create windws job/tasks to run the batch file