- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- basic script (for you guys anyway!)
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 05:06 AM
05-01-2002 05:06 AM
I have a list of .dbf files in a directory, that I would like to 'gzip' up, depending on their date.
At the moment I run:
for i in `ls -1 |grep _1`
do
gzip $i
done
This will zip any files with _1 in the name.
I would like to keep the last 7 days files, so need to use the find command I guess, with -mtime to search for files greater than 10days (ignoring the . & .. entries, and the one .conf file in the list) and gzip them, then maybe report what it's done to an email address... only if it's had to gzip something... if no work had to be done.. no email is sent.
thanks eveyone..
Nik
btw: I'm still working on it now... but I'm sure someone will have a clever 2 liner that'll do it in half the time!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 05:10 AM
05-01-2002 05:10 AM
Re: basic script (for you guys anyway!)
You are on the right track, keep scripting!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 05:25 AM
05-01-2002 05:25 AM
SolutionThis should help you on your way
---------------
#delete .dbf files over 7 days old
find . -name "*.dbf" -mtime +7 -exec rm -f {} \;
test -f *.dbf
#if .dbf files exist gzip them and mail dir listing to a user
if [[ $? = 0 ]]
then
for i in $(ls -1 *.dbf)
do
gzip $i
done
ls -la /directory | mailx -s "files are" username@domain.com
fi
----------------
Regards,
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 05:28 AM
05-01-2002 05:28 AM
Re: basic script (for you guys anyway!)
--------------------
#delete .dbf files over 7 days old
find . -name "*.dbf" -mtime +7 -exec rm -f {} \;
#if .dbf files exist gzip them and mail dir listing to a user
test -f *.dbf
if [[ $? = 0 ]]
then
for i in $(ls -1 *.dbf)
do
gzip $i
done
ls -la /directory | mailx -s "files are" username@domain.com
fi
---------------
Regards,
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2002 05:32 AM
05-01-2002 05:32 AM
Re: basic script (for you guys anyway!)
James: thanks for the motivational reply! I would assign points, but 20,000(!) I figure you have enough already! :)