Shell script to check the files hourly and purge


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to check the files hourly and purge
# 1  
Old 02-26-2009
Shell script to check the files hourly and purge

I'm new to shell scripting... i have been given a task.. can any one help in this regard....


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
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 zgip)




Thanks
Satish
# 2  
Old 02-26-2009
Looks like classroom stuff which is against the rules:

The UNIX and Linux Forums - Forum Rules

Closed.

Edit: Just found your partially double posted thread. Double/cross posting is forbidden too.
https://www.unix.com/shell-programmin...ript-unix.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check a file and delete old files

Hello, I needed help with a shell script where in it checks if a file exists under a directory and also checks the age of the file and delete it if it is older than 3 weeks. thanks (10 Replies)
Discussion started by: hasn318
10 Replies

2. Shell Programming and Scripting

Shell/perl script to check for files

Hi, I am trying to write a script for following scenario: I have a list of countries from where I receive files...eg. (Indonesia, Thailand, Australia...etc) For each country, I have a list of files that they send. IND -- a,b,c TH -- p,q,r AU -- x,y,z The path for these files could... (2 Replies)
Discussion started by: neil.k
2 Replies

3. Shell Programming and Scripting

How to check whether directory has files in it or not in shell script?

hi, I am having script in which i want to check if directory has any file in it or not. If directory contains a single or more files then and only then it should proceed to further operations... P.S.: Directory might have thousand number of files. so there might be chance of getting error... (4 Replies)
Discussion started by: VSom007
4 Replies

4. Shell Programming and Scripting

Shell script to check files if exist else touch the file

Hi All, Thanks in Advance I wrote the following code if then echo "version is 1.1" for i in "subscriber promplan mapping dedicatedaccount faflistSub faflistAcc accumulator pam_account" do FILE="SDP_DUMP_$i.csv" echo "$FILE" ... (5 Replies)
Discussion started by: aealexanderraj
5 Replies

5. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

6. Shell Programming and Scripting

To create a script and schedule which purge 30 days old files

Hi Friends, Very new in Unix and i got a requirement like writing a script and schedule it, so that it removes 30 days old files from all the log locations of a unix box. Suppose i have a unix server ltbamdev1 and in this server i have a mount point opt/bam. In this mount point i have 3... (1 Reply)
Discussion started by: duos
1 Replies

7. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

8. Shell Programming and Scripting

HOW TO CHECK ONLY .C FILES EXISTS OR NOT IN A FOLDER using IF in C shell script?

Hi friends.. I hav a problem.... I dont know how to check .c files exists r not in a folder using IF in C shell script actually i tried like this if(=~ *.c) even though some .c files or there in the current folder..it is not entering int o the if control statement...... (17 Replies)
Discussion started by: p.hemadrireddy
17 Replies

9. Shell Programming and Scripting

shell script for archive purge

I am writing a shell script for Archive Purge for the table having rows < 1 year. The shell script has to extract the rows from the table and write those extracted rows to a text file. Then from the text file, each rows will be read and deleted by means of delete query one by one. The fields will... (5 Replies)
Discussion started by: regnumber
5 Replies

10. UNIX for Dummies Questions & Answers

How do you automate an hourly file check?

Hi, New to the forum, Great site, I can learn a lot from here!! :cool: I would like to know how to automate a command that checks the Sybase database's are "alive" on an hourly basis, and mails outlook if they are not (1 Reply)
Discussion started by: mals
1 Replies
Login or Register to Ask a Question