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
03-05-2003 09:19 AM
03-05-2003 09:19 AM
filedate
but how to determine a file creation date in seconds? Is there one command like filedate in solaris? I want to delete some files older than 30 minutes. Find's -ctime only accepts days.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 09:22 AM
03-05-2003 09:22 AM
Re: filedate
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 12:23 PM
03-05-2003 12:23 PM
Re: filedate
find . -mtime +1 -exec rm {} \;
This would delete everything older than one day.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 03:55 PM
03-05-2003 03:55 PM
Re: filedate
echo 12345i |fsdb /dev/vgxx/lvolX
where 12345 is your inode number of file.
This will tell ctime.mtime atime which you can grep for doing stuff,
But I will agree with earlier approach of touching a file and then using -newer option in find...
hope this helps..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 04:04 PM
03-05-2003 04:04 PM
Re: filedate
Pete's method can be used to achive your task.
Create a file by touching it with a timestamp of 30mins back. Then use find with -newer option.
$touch 0305173003 myreference
This creates the file myreference stamped with 17:30 hrs today.
$find /dir -newer myreference
Use it with exec or xargs to delete the thus found files.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2003 05:36 PM
03-05-2003 05:36 PM
Re: filedate
Yes there are ways to find the time of file in seconds but not a straight one. You'll have to write a C program using stat() function and extract st_mtime in structure stat.
Let me know if you need the codes i have for this.
Rajeev
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2003 04:26 AM
03-06-2003 04:26 AM
Re: filedate
attached is something similar I once did myself. The attachment consists of two scripts.
The following variables of the first script must be configured:
RETURN_SECONDS must point to the second script in the attachment!
DIR must specify the directory starting point under which the files are to be deleted.
AGE must specify in seconds how old the files are allowed to be.
The first script, which is the one you must execute, tries to convert passed seconds into a more user-friendly date format: the month is expressed as three chars, e.g. May or Maj or something else (language dependent). As I do not know which language you use, the script may not make the correct mapping and might therefore fail. Hope you can correct this yourself in the case sentence.
The script makes use of the find command:
! -newer
which means "older than". If you are 100% sure that you get hold of the correct files, you can change the ls -l to rm in the find command. Be really careful.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2003 05:10 AM
03-07-2003 05:10 AM
Re: filedate
Neither of these was exactly what I was looking for. I think you cannot really deside with shell scripts if a file is older than X seconds (X is configureble parameter) or not. Or at least is too complicated:)
I wrote a little C code and attached. Feel free to use it...
Usage: filedate [-f filename] [-d duration] [-p] [-h]
-d duration exit code 1 if file older than specified duration
duration is in sec. default is 12 hours.
-f filename Checks the data modification date of the specific file
-h Wot d'ya think? :-)
-p Prints the date of the file in %c%y/%m/%d %H:%M:%S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2003 12:32 PM
03-07-2003 12:32 PM
Re: filedate
Remember that the -M test takes the seconds since the epoch when your script started and substracts the file's mtime in seconds since the epoch, and returns the value in days.
(this is much better explained in the POD, type "perldoc -f -x")
So a oneliner to demostrate:
# touch /tmp/smp;sleep 12; perl -e '$t=-M "/tmp/smp";print $t*=86400,"\n"'
12