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
04-26-2004 05:00 PM
04-26-2004 05:00 PM
This creates folders like:
/var/opt/ignite/recovery/2004-03-21,04:08
/var/opt/ignite/recovery/2004-03-28,04:09
/var/opt/ignite/recovery/2004-04-04,04:08
/var/opt/ignite/recovery/2004-04-11,04:09
/var/opt/ignite/recovery/2004-04-18,04:09
/var/opt/ignite/recovery/2004-04-25,04:08
I want to write a script which will check the /var/opt/ignite/recovery folder and remove the 2004-XX-XX,0X:XX folder which is dated last month.
Here I would like to remove:
/var/opt/ignite/recovery/2004-03-21,04:08
/var/opt/ignite/recovery/2004-03-28,04:09
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2004 05:09 PM - last edited on 09-16-2024 02:19 AM by support_s
04-26-2004 05:09 PM - last edited on 09-16-2024 02:19 AM by support_s
SolutionTo get the directory.
#find /var/opt/ignite/recovery -type d -a -mtime +30 -exec ls -d {} \;
to delete the direstory
#find /var/opt/ignite/recovery -type d -a -mtime +30 -exec rm -R {} \;
- Tags:
- virtualization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2004 06:29 PM
04-26-2004 06:29 PM
Re: script
# date ; perl -MTime::Local -le '@t=localtime;$t[4]--;print scalar localtime timelocal@t'
Tue Apr 27 08:15:30 CEST 2004
Sat Mar 27 08:15:30 2004
But this will fail for 31 March, because 31 February does not exist:
# date ; perl -MTime::Local=timelocal_nocheck -le '@t=localtime;$t[4]--;$t[3]=32;print scalar localtime timelocal_nocheck@t'
Tue Apr 27 08:22:58 CEST 2004
Thu Apr 1 08:22:58 2004
which forced the date to the 32nd before converting back. If that behaviour is acceptable
# perl -MTime::Local=timelocal_nocheck -e'@t=localtime;$t[4]--;@t=localtime timelocal_nocheck@t;$f=sprintf"%4d-%02d-%02d",1900+$t[5],1+$t[4],$t[3];$file=<$f,* >'
Tue Apr 27 08:15:30 CEST 2004
Sat Mar 27 08:15:30 2004
Will give you the file with the date last month in $file
If you rather not look at month', but use a fixed 30 day period,
# perl -e'@t=localtime(time-30*86400);$f=sprintf"%4d-%02d-%02d",1900+$t[5],1+$t[4],$t[3];$file=<$f,* >'
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2004 07:10 PM
04-26-2004 07:10 PM
Re: script
I was just wondering....what would be wrong with this approach:
#!/usr/bin/sh
# Delete older than current month from FOLDER
FOLDER= # path to ignitefolders
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%m)
DEL_MONTH=""
DEL_YEAR=""
# Construct pattern for deletion
if [ "$CURRENT_MONTH" = "01" ]
then
DEL_MONTH="12"
else
DEL_MONTH=$CURRENT_MONTH
fi
if [ "$DEL_MONTH" = "12" ]
then
DEL_YEAR=$(($CURRENT_YEAR - 1 ))
else
DEL_YEAR=$CURRENT_YEAR
fi
ls -l ${FOLDER}/${DEL_YEAR}-${DEL_MONTH}-*
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2004 07:28 PM
04-26-2004 07:28 PM
Re: script
Change the line DEL_MONTH=$CURRENT_MONTH to
(( DEL_MONTH = $CURRENT_MONTH - 1 ))
and it will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2004 08:17 PM
04-26-2004 08:17 PM
Re: script
Thanks Elmar, you are of course right! Now I wonder how I managed to miss the most important point.
regards,
John K.