The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

automate download of access log files

Discussion in 'General Discussion' started by keesha, Jul 30, 2004.

  1. keesha

    keesha Registered

    Joined:
    Jul 28, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I need to copy my site's access log files to a different directory so that the data can be accessed by an application I'm building. I am having a problem with the script that copies the file. Everytime I run it, it creates a blank file.

    I contacted my hosting company and was told that they clear the log files weekly and that the location to the files were, "/apache/domlogs/domainname.log". Going by an example posted by one of the members to this forum (http://www.annelisabeth.com/pc/pc13.htm), I have tried every different variation of paths to the original log files that I could think of, but still no luck.

    Can anyone please help me with this? Am I overlooking something simple? If someone can help me get this working, I'll make it worth your while. ;)

    PHP:

    $yesterday 
    mktime(0,0,0,date("m"),date("d")-1,date("Y"));
    $yesterday strftime("%d/%b",$yesterday);

    $thatday mktime(0,0,0,date("m"),date("d")-1,date("Y"));
    $thatday strftime("%Y%b%d",$thatday);

    exec("gzip -dc /apache/domlogs/widgets.com.log | grep '$yesterday' | gzip -9 >> /home/widgets/logs/newaccesslog_widgets.com$thatday.gz");


     
  2. AnthonyR

    AnthonyR Active Member

    Joined:
    Oct 28, 2003
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Shouldnt the log path be - /usr/local/apache/domlogs/domainname.com (*note -without the .log)

    If you go to SSH and type

    cd /usr/local/apache/domlogs/
    ls yourdomain*


    Does it give you a list of log files?? If so then the above would be the correct path.
     
    #2 AnthonyR, Jul 30, 2004
    Last edited: Jul 30, 2004
  3. keesha

    keesha Registered

    Joined:
    Jul 28, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I've never used SSH before. Is there a client built in cpanel somewhere, or do I have to download and install one? Or do I have any other options?
     
  4. AnthonyR

    AnthonyR Active Member

    Joined:
    Oct 28, 2003
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    There is a Java based client in cpanel - however you may need your host to open up SSH for you.
     
  5. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
  6. AnthonyR

    AnthonyR Active Member

    Joined:
    Oct 28, 2003
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Putty is good - I use it :)

    You dont need root access to use putty either, if your host opens SSH for you.

    Maybe the best thing to do would be to ask your host to look at the script for you - its not hard for them as they know the paths.

    I certainly would help one of our clients with something like this.
     
  7. keesha

    keesha Registered

    Joined:
    Jul 28, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I have tried to view the files in the /usr/local/apache/domlogs/ directory using putty and it said "Permission denied" (as I expected).

    However, I figured out how to copy the log file if I do the following in putty:
    PHP:
    cp -/usr/local/apache/domlogs/widgets.com /home/widget/logs/test.txt
    Any ideas on how to set it up to copy the file automatically?
     
    #7 keesha, Aug 4, 2004
    Last edited: Aug 4, 2004
  8. keesha

    keesha Registered

    Joined:
    Jul 28, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Ok, I figured out a workaround with my problem. I could set up a cron job to run the command to copy the file. Then I could set another cron job to run the application script after the log file has been transferred.

    Are there any negative issues with doing it this way?
     
Loading...

Share This Page