Housekeeping script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Housekeeping script
# 1  
Old 11-27-2012
Housekeeping script

I have a directory ( eg. /tmp , there are many files in it , I would like to do the houskeeping job , can advise how to develop a script to do the following .
1) if the files are elder than 10 days in this directory , the extension is .txt , then move it to /tmp/tmp-txt , the same , if the files are elder than 10 days in this directory , the extension is .csv , then move it to /tmp/tmp-csv
2) if the files in /tmp/tmp-txt and /tmp/tmp-csv are elder than 30 days , then tar it to a file and remove it from this directory .
# 2  
Old 11-27-2012
Code:
find /tmp -type f -mtime 10 -maxdepth 0 -name \*.txt mv {} /tmp/tmp-txt \;

For part 2, do you mean, if there is no file younger than 30 days, tar up the directory, or do you mean if there are any files older than 30 days tar up the directory?
# 3  
Old 11-27-2012
Quote:
Originally Posted by Skrynesaver
Code:
find /tmp -type f -mtime 10 -maxdepth 0 -name \*.txt mv {} /tmp/tmp-txt \;

For part 2, do you mean, if there is no file younger than 30 days, tar up the directory, or do you mean if there are any files older than 30 days tar up the directory?
thanks reply ,

I mean if the files are older than 30 days, then tar these files ( do it once / month ) .

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

[Tip] Housekeeping Tasks Made Easy - User Home directories and Leftover Files

We have regularly questions about how to create users and user accounts. But regularly user accounts need to be deleted too. It is quite easy to delete the user account itself but usually the HOME directory of the user remains. It is good style to remove these directories but simply deleting... (3 Replies)
Discussion started by: bakunin
3 Replies

2. AIX

Housekeeping null 2>&1 in /dev

Hello, Does anyone know how to housekeeping the null 2>&1 file in /dev? its fill up my system, please help. Thanks :b: (3 Replies)
Discussion started by: only
3 Replies

3. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

4. HP-UX

Problems after filesystem housekeeping

I have noticed that after I clear up the /var filesystem, there are always problems. Does deleting the OLDsyslog.log file cause problems like missing directories and problems accessing crontabs? There were two situations where I faced problems. 1) Deleted OLDsyslog.log (Of course I created... (5 Replies)
Discussion started by: anaigini45
5 Replies

5. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

6. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

7. Shell Programming and Scripting

Housekeeping Not Working

Hi, I have a .ksh script which finds all the directories older than 84 days and tries to housekeep. Below is the command used find * -depth -type d -ctime +84 -exec rm -rf {} \; The above command lists all the directories ie child and parent directory in descending order which are more... (10 Replies)
Discussion started by: annamalai77
10 Replies

8. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

9. Shell Programming and Scripting

housekeeping

hey, I have to write a housekeeping script which would delete any files which are more than 10 days old, the file is named in such a fashion MYTEST20060101_182239.txt MYXML20060112_182879.xml MYEXCEL20060113_546321.xls If the current date is 20060112, then MYTEST20060101_182239.txt will be... (2 Replies)
Discussion started by: mpang_
2 Replies
Login or Register to Ask a Question