nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

shell script to zip old files and then delete

This is a discussion on shell script to zip old files and then delete within the Shell scripting forums, part of the Development/Scripting category; Hi All, Good day, we have few RHEL 3/4 servers and whose disk space always be 100% (/opt) and we ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-10-2009, 03:40 PM
Junior Member
User
 
Join Date: Mar 2009
OS: Red hat Linux
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
shankar43 is on a distinguished road
Default shell script to zip old files and then delete

Hi All,

Good day,

we have few RHEL 3/4 servers and whose disk space always be 100% (/opt) and we need to manually delete some logs to free up space. we now decided to write up some shell script to automate the works. The requirement was given by my lead to start the work. I am not good at shell script so though of asking you guys for help. here is the requirement,

/opt/jboss-4.2.1/server/bos/log/BOS-APP-SERV1_bos-server.log.2009-02-20-16

Example (using sym link) would be:

Source path: /opt/jboss/server/bos/log
Source template : [hostname]_bos-server.log.*


1) Check hourly for files in <destination-path><destination-file-template><destination-file-suffix> for files older than <destination-file-retention> days and purge. It should then check <source-path><source-file-template> for files older than <source-file-retention> and compress them based on <tar-flag> or <gzip-flag> or both. The compressed files should be in <destination-path><destination-file-template><destination-file-suffix>.



2) Provide variable parameters for the following, clearly commented, at the top of the script

Source-path # Source location for files matching source file template
Source-file-template # File name template
Source-file-retention # Files older than (hours) will be processed
Destination-path # Destination may be same or different than the Source path
Destination-file-suffix # None or specified)
Destination-file-template # Could equal source file template or be a combination of source plus suffix
Destination file retention (days) # Files older than this are deleted (usally 3 days old)
Tar flag # If true or y then use tar
Gzip flag # If true or y then use gzip (may both be set for tar and gzip)

Please help us on this.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-11-2009, 05:22 AM
Junior Member
User
 
Join Date: Feb 2008
OS: .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
unSpawn is on a distinguished road
Default

Quote:
Originally Posted by shankar43 View Post
I am not good at shell script so
Question is: do you want to be? I mean, you're good at copying requirements verbatim (do services in general like it to get their logs rotated from under them w/o some form of -HUP?) but you haven't shown any (pseudo) code one could help you improve?..
Reply With Quote
  #3 (permalink)  
Old 03-13-2009, 09:10 AM
Junior Member
User
 
Join Date: Mar 2009
OS: Red hat Linux
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
shankar43 is on a distinguished road
Default

Question is: do you want to be?

no, i will try to write a script myself and update it here if required any help. I think this is the way it works.

Thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Script to delete a set of files in Remote machine ashok333 Shell scripting 4 05-09-2008 07:24 PM
Shell Script to Automatically Delete a File via Cron Job kakarla Shell scripting 2 01-29-2008 08:54 AM
i need a script to delete one folder with files on my ftp silver_ch Shell scripting 1 03-27-2007 10:15 AM
Shell script to delete a file with a dialog utility shankar100 Shell scripting 4 03-02-2007 10:22 AM
Shell script for automatic conversion of files in tar files kasimani Shell scripting 2 02-08-2007 03:45 PM


All times are GMT +5.5. The time now is 01:42 AM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38