Script to tar up old log files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to tar up old log files
# 1  
Old 09-25-2003
Script to tar up old log files

Hell All! I need help writing a script for my job. I never really wrote alot of scripts but I guess it a first time for everything. I need to write a simple script that goes out to our log file directory on our servers and tar and compress them. I need to know how to add an date time stamp to tell which logs to tar up and compress. Can someone please help me wiht this?
# 2  
Old 09-25-2003
Any chance you can show us what you have ???
# 3  
Old 09-25-2003
Don't know, but maybe :


mkdir /dir/to/my/path/tmp

for i in `find /dir/to/my/path -type f -mtime +10`
do
mv $i /dir/to/my/path/tmp
done

tar cvf /tmp/backup_file.tar /dir/to/my/path/tmp
rm -r /dir/to/my/path/tmp

Regs David
# 4  
Old 09-25-2003
Quote:
I need to know how to add an date time stamp to tell which logs to tar up and compress
As Davidg has shown in his example, you can find a set of files by evaluationg the modification time for the file. Check out the find and look specifically at the -mtime flag.
# 5  
Old 09-26-2003
Thank You

I want to say Thank You to the members that help me out with my question. I finish my script and it works great. Thank you all. Smilie
# 6  
Old 02-17-2008
hi aojmoj...

is it okay if you can post your script here???

Thanks & congrats you manage to create your script... Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Back up log files using tar

Hi, I need some help writing a perl script to tar all log file to a directory and then delete the log files. Can some one please help me on this? I m Not very good with perl scripting... Thanks KK (4 Replies)
Discussion started by: karthikk0508
4 Replies

2. Shell Programming and Scripting

How to tar files inside a script?

Hi , I have a file which contains few file names. I need to tar those files but am unable to do inside the script. Any help will be useful. cat /tmp/test aa.txt bb.txt cc.txt I have tried the below code but its not working. for i in `cat /tmp/test';do tar -cvf TEST.tar $i;done (9 Replies)
Discussion started by: rogerben
9 Replies

3. Shell Programming and Scripting

Issue in Untaring the Tar files Script

I have written a below script to untar the tar files from /tmp/tarfiles/ directory. # cat /tmp/tarfiles/script.sh #!/bin/sh cd /tmp/tarfiles/ TFL="tar_files_list.txt" TCF="tar_completed_list.txt" ls -l *.tar | awk '{print $9}' > $TFL for i in `cat $TFL` do if then for j in... (2 Replies)
Discussion started by: thomasraj87
2 Replies

4. Shell Programming and Scripting

Backup script to split and tar files

Hi Guys, I'm very new to bash scripting. Please help me on this. I'm in need of a backup script which does the ff. 1. If a file is larger than 5GB. split it and tar the file. 2. Weekly backup file to amazon s3 using s3rsync 3. If a file is unchanged it doesn't need to copy to amazon s3 ... (4 Replies)
Discussion started by: ganitolngyundre
4 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. Shell Programming and Scripting

Need script to tar files older than 30 days

Hi all. Here's my situation: I have performance reports that run every 30 minutes saved in the format: stats_report_11251000.txt stats_report_11251030.txt stats_report_11251100.txt stats_report_11251130.txt (Obviously run at Nov 25 10 AM, 10:30 AM, 11 AM and so on...) I would... (2 Replies)
Discussion started by: jamie_collins
2 Replies

7. Shell Programming and Scripting

To write a shell script which groups files with certain pattern, create a tar and zip

Hi Guru's, I have to write a shell script which groups file names based upon the certain matching string pattern, then creates the Tar file for that particular group of files and then zips the Tar file created for the respective group of files. For example, In the given directory these files... (3 Replies)
Discussion started by: rahu_sg
3 Replies

8. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

9. Shell Programming and Scripting

bash - batch script for extracting one file from multiple tar files

so i have hundreds of files named history.20071112.tar (history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies

10. Shell Programming and Scripting

How to process the files using .tar.gz files in script

Hi, I have some file in /users/xyz directoty with .tar.gz extension. i need to find these files and if found in need to run other commands. I now the command for finding files,but how to put if condition ?please help me Thanks (3 Replies)
Discussion started by: bmkreddy
3 Replies
Login or Register to Ask a Question