- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- date script
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
01-24-2002 04:14 AM
01-24-2002 04:14 AM
date script
What am I missing.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2002 04:36 AM
01-24-2002 04:36 AM
Re: date script
Example please of extension used
for previous and todays date plus what you tried
You can always touch a file with an mtime of today at 06:00 and then find files older
and delete them.Then remove touch file.
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2002 04:44 AM
01-24-2002 04:44 AM
Re: date script
Try this find statement :
find /u004/ftp/cash/if/in/cop/archive/ -name icstc_v100_a??????_0??.??-??-??
-exec rm {} \;
You can replace the last question marks by a parameter, that you can enter.
Rgds
Alexander M. Ermes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2002 04:53 AM
01-24-2002 04:53 AM
Re: date script
I suppouse that you have files with names like this:
filename.yyyymmdd
If it is you can do a script that keep the today date and rm all the files with an extension minor than today.
Something like this:
cd your directory
date=$(date +%Y +%b +%d)
for i in `ls`
do
extension=$(echo $i | cut -d. -f2)
if [ $extension -lt $date ]
then
file="\*"+"\."+${extension}
rm ${file}
fi
done
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2002 07:08 AM
01-24-2002 07:08 AM
Re: date script
or
today=todays_extension
find /your_dir -type f|grep -v $today|xargs rm
Will do it if you want to remove all but todays files.
or
find /yourdir -type f -mtime +1|xargs rm
kill more than 1 day old
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2002 07:14 AM
01-24-2002 07:14 AM
Re: date script
I've attached a date script called caljd.sh; this will do almost any date problem; in this case it's overkill but this is my date hammer and every date problem is a nail.
FILENAME=myfile
SUFFIX=$(caljd.sh -y -s $(caljd.sh -p 1))
FULLNAME="${FILENAME}.${SUFFIX}"
This will result in a filename for the previous day of "myfile.20020123".
The inner caljd.sh uses the -p 1 argument to find the julian day 1 day previous. The outer call the converts that julian day into YYYY MM DD (the -y argument) and the -s removes the spaces to yield "YYYYMMDD". Invoke caljd.sh -u for full usage. With this you can skip weekends or holidays, leap years don't matter, or change the number of days previous.
If you start using this script, I think you will use nothing else for a date calculation within a script.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2002 07:18 AM
01-24-2002 07:18 AM
Re: date script
If you have the date in the format: filename.yyyymmdd. You can write your script to make use of the fact that the files are sorted numerically in ls.
This script will remove all filename.* logs except the latest log (ie. today's log):
==========================================
#!/sbin/sh
current=`ls filename.*|tail -1`
for file in filename.*
do
if echo $file | grep $current
then
: # today's log, do nothing
else
rm $file # remove this log
fi
done
==========================================
Hope this helps. Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2002 08:41 AM
01-25-2002 08:41 AM
Re: date script
cd /hbo/audittest
find . -type f -mtime -1 -exec rm -f {} \;
thanks for everyones help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2002 08:48 AM
01-25-2002 08:48 AM
Re: date script
In that case, you need to change your -1 to +1 (older than 1 day). I a little surprised because this stuff has nothing to do with suffixes as your original post indicated.