LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-08-2004, 04:17 AM   #1
aLiVe
LQ Newbie
 
Registered: Jul 2004
Posts: 5

Rep: Reputation: 0
Unhappy Need help from pros in shell script


I am new to linux and so unfortunately i was ask to create a script that can zip up the web logs that are generated by Apache and Tomcat web server. After zipping up the logs, it clears the old logs and send the zipped logs to a ftp server. Lastly, the script has to be executed once a month. I really have no clue on how to do it. Can anyone help me?
 
Old 08-08-2004, 04:50 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
I would try something like this :

Code:
#!/bin/bash

TEMP_DIR="/home/tmp"

FTP_HOST="ftp.myhost.com"
FTP_USER="me"
FTP_PASSWORD="password"
FTP_DIR="/path/to/backup/logs"
FTP_URL="ftp://$FTP_USER:$FTP_PASSWORD@$FTP_HOST$FTP_DIR/"
FTP_UP=

APACHE_LOGS_DIR=/var/log/apache

cd $TEMP_DIR

for log in `ls $APACHE_LOGS_DIR`; do
    LOG_NAME=$(basename $log)
    zip -j "$LOG_NAME.zip" $log
    FTP_UP="$FTP_UP  -T $LOG_NAME.zip $FTP_URL"
done

curl  -w '%{size_upload} bytes uploaded\n' $FTP_UP
Then I would save it as log_backup.sh for example, and edit crontab like :
Code:
30 12 1 * * /path/to/log_backups.sh
So it will run the first day of the month at 12:30 am

I did not add line to delete old log files and zip files so you can test the script before final stage

Last edited by Cedrik; 08-08-2004 at 04:52 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Shell scripting pros herve2001 Linux - Newbie 2 02-24-2005 01:13 PM
Need help from pros in shell scripting? aLiVe Linux - Newbie 18 08-12-2004 09:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration