SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need newbie help with cron and copying files

    i want to copy a file from the logs directory on the webserver to a folder within my virtual directory, what is the syntax to do this?

    i already know how to setup the time format so it runs once a month, its the rest that escapes me. also, the log file that i will be downloading changes its name each day, in the format www.websitename.com-10-10-2002.tgz. are the paths relative or physical also?

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    #! /bin/sh
    
    # log directory
    logsdir=/var/log
    
    # web site
    website=www.website.com
    
    # target folder
    target=~/myfolder
    
    cp $logsdir/$website.`date +%m-%d-%Y`.tgz $target
    change the variables as needed, save it as a script, chmod to add execute permissions, and then point to the script with your cron task.

    or, as a less robust, but more efficient alternative, put the following command in as the cron task:
    Code:
    cp /var/log/www.website.com.`date +%m-%d-%Y`.tgz ~/mydirectory
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks randem.

    is there a way to do it with a URL also?

  4. #4
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm not sure i understand what you're asking.
    ----Adopt-a-Sig----
    Your message here!

  5. #5
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    instead of putting the copy from as a folder, as a url instead. i figured out that i don't need to do that though.

    i can't get the date function to work in this code
    Code:
    cp /usr/local/apache/domlogs/woodthatrocks.com /home/loginName/public_html/log/logged.`date +%m-%d-%Y`.txt
    it spits out an error.


Bookmarks

Posting Permissions

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