- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- help on date of file
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
06-06-2006 09:02 PM
06-06-2006 09:02 PM
I would like to ask on how to move my files that is 3 days old from the time it is created whether it is accessed or not. Is this possible is a one line command format or in a script?
Maximum points for all correct replies.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2006 09:05 PM
06-06-2006 09:05 PM
Re: help on date of file
or is there a script out there available for me to use? Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2006 09:12 PM
06-06-2006 09:12 PM
Re: help on date of file
I think this is the same question for which you started a thread.
Your problem statement is not very clear.
You say - a file which is 3 days old from the time it is created. If a file is created on date x how can it be 3 days older than x ?
Now if you mean you want to find files which were created 3 days or more ago than today - you have a valid question.
In that case I would like to reiterate what I said to your earlier post - you cannot determine in Unix if a file was created at so and so time [ or so many days ago ] what you can find is if a file was modified x days ago or not.
So you can find files which were modified 3 days or more ago and havent been modified in last 3 days ; but you will not be able to find out a file which was created x days ago but has been modified in the last 3 days as Unix maintains only modification time and access times - not creation times of files
Hope this clarifies.
Regards,
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2006 12:15 AM
06-07-2006 12:15 AM
Re: help on date of file
Not sure if I'm interpreting your question correctly. If you want to move any files in /foo/dir1 that have not be accessed in more than 3 days to /foo/dir2, you could do:
find /foo/dir1 -type f -atime +3 -exec mv {} /foo/dir2 \;
As Ninad said, HP-UX does not store a file's creation time. The closest thing to this is the last modification time of a file's inode, but many activities will cause this time to be updated (file created, mode changed, etc.). 'ls -lc' will give you a long listing sorted by last inode modification time.
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2006 12:25 AM
06-07-2006 12:25 AM
Re: help on date of file
Check this thread.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=918050
Regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2006 12:49 AM
06-07-2006 12:49 AM
Re: help on date of file
I usually use modify time as basis.
And for safety I tar them first using
xargs.
(I found the -exec not usefull when moving,
it is okay when rm or grep)
Anyway here it is:
1) Find . -print -type f -mtime +3 | xargs
tar -cvf new.tar ; mv new.tar /newpath
Nice , safe and clean.
Plus you can output to a log to
see what happened afterwards
(mv is rather silent)
You can check the tar at new
destination with tar -tvf new.tar
Keep cooking:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2006 08:56 AM
06-07-2006 08:56 AM
Re: help on date of file
Sorry that vague question. When you do an ll command, i see on my screen the following:
# ll
-rw-rw-r-- 1 idsdb users 2644 May 29 11:05 E-BC-0619-0826.xml
-rw-rw-r-- 1 idsdb users 2641 May 29 11:05 E-BC-0619-0830.xml
The above list a date and time stamp (May 29 11:05). Is this the creation date and time?
What i really want to do is that 3 days after May 29 11:05 (that's should be Jun 1 11:06), these files will be move to an archive directory.
I hope this clarifies my inquiries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2006 09:04 AM
06-07-2006 09:04 AM
SolutionNow to move files that have not been modified in more than 3 days, you should create a cron job that runs everyday at some
preferred time and run a script something like this:
#!/usr/bin/sh
SRCDIR=/xxx/yyy
DESTDIR=XXX/YYY.save
cd ${SRCSRC}
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
find . -type f -mtime +3 -exec mv {} ${DESTDIR}/ \;
STAT=${?}
else
echo "Can't cd to ${SRCDIR}; status ${STAT}." >&2
fi
exit ${STAT}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2006 06:51 PM
06-07-2006 06:51 PM
Re: help on date of file
Thanks for that wonderful insight. The code helps me a lot! Thanks!