- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to know if data is being accessed
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-24-2003 01:05 PM
03-24-2003 01:05 PM
I have a script that runs periodically and changes permissions on new data that shows up in a certain directory. I find new data by comparing the output from a previous "ls" with the output from a new "ls". People will be continuously moving data into this directory. I was going to run my script periodically using cron, but how can I be sure that the new data I see using "ls" has completed its move and is not still in the process of being moved??
Thanks,
Theresa
P.S. I will be on Tuesday but look forward to reading your responses on Wednesday! Thanks!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2003 01:19 PM
03-24-2003 01:19 PM
Re: How to know if data is being accessed
Oneway I would do is to use fuser command. If you use fuser against a file that is being accessed, it will print out the pid of the process. So, fuser returns anything, then you would skip copying that file or wait until it is done. You can accomplish it using a while statement with a sleep in it.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2003 01:34 PM
03-24-2003 01:34 PM
Re: How to know if data is being accessed
An other way is using losf.
take a look at the man page.
http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.64/
Hope it helps,
Robert-Jan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2003 01:54 PM
03-24-2003 01:54 PM
SolutionAGE=300
ls | while read FNAME
do
fileage.pl -m -s ${AGE} ${FNAME}
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "${FNAME} has not been modified in ${AGE} seconds."
echo "It is safe to copy."
fi
done
Fileage.pl returns 0 if a file has not been modified in a given period; 1 if it has, and > 1 on error.
Invoke as fileage.pl -u for full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2003 03:06 PM
03-24-2003 03:06 PM
Re: How to know if data is being accessed
A note of caution: Changing the name, the permissions or the ownership of a file or moving it from one directory to another updates the inode change timestamp as divulged by 'ls -lc'. Beware that 'fbackup' (if you use it) will also change this when it restores the lastaccess timestamp (ls -lu) of a file it copies.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2003 10:24 AM
03-26-2003 10:24 AM
Re: How to know if data is being accessed
Thanks for your responses.
I didn't try it, but I don't know if fuser would work if people were writing to this file/directory via nfs. I did, however, use the while statement with a sleep in it. Instead of fuser, I used Clay's suggestion of "find -newer my_touchfile" for a quick and dirty solution. It works great. The other suggestions may be better, but since I needed this done by this afternoon, I didn't have time to download lsof or to get the perl script working.
Thanks again!
Theresa