Writing a Cron Job

Discussion in 'Site & Server Administration' started by circuscircus, Feb 8, 2007.

Thread Status:
Not open for further replies.
  1. #1
    How do I write a cron job that...

    Gzips my logs each night?
     
    circuscircus, Feb 8, 2007 IP
  2. soniqhost.com

    soniqhost.com Notable Member

    Messages:
    5,887
    Likes Received:
    96
    Best Answers:
    0
    Trophy Points:
    240
    #2
    Are you using Cpanel?
     
    soniqhost.com, Feb 8, 2007 IP
  3. niloy

    niloy Banned

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    From shell, type this to open the crontab:

    crontab -e
    then place a line like this:

    0 0 * * * * tar -cvfz /pathofyourlogs /root/logfiles.tar.gz

    Change pathofyourlogs to the path of your log files and this will save the log files in the root floder with logfiles.tar.gz named.
     
    niloy, Feb 8, 2007 IP
  4. circuscircus

    circuscircus Peon

    Messages:
    240
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How would I add into that to ALSO

    restart the server every hour between the times of 7:00AM to 3:pM?
     
    circuscircus, Feb 9, 2007 IP
  5. theblight

    theblight Peon

    Messages:
    246
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If this is the server
    0 7,8,9,10,11,12,13,14,15 * * * * init 6
    OR
    0 7,8,9,10,11,12,13,14,15 * * * * command restart
    OR
    0 7,8,9,10,11,12,13,14,15 * * * * <command>

    :cool:
     
    theblight, Feb 10, 2007 IP
Thread Status:
Not open for further replies.