- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How can I know that a file 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
Discussions
Discussions
Forums
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
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
тАО12-21-2007 08:26 AM
тАО12-21-2007 08:26 AM
Re: How can I know that a file is being accessed ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-21-2007 10:41 AM
тАО12-21-2007 10:41 AM
Re: How can I know that a file is being accessed ?
I have described my probem in detail in one of my previous posts (20 december). I do not know what more I can say ?
But the statement ll -u gives me almost what I need. It just gives me the time, but I cannot test on the time to see if the file is currently being accessed (as I have to wait until the file is being accessed to delete it).
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-24-2007 07:23 AM
тАО12-24-2007 07:23 AM
Re: How can I know that a file is being accessed ?
one other strategy that might work. Create your pdf, then create another file of the same name (but w/o the .pdf extension) like myfile.pdf and myfile. The of creation must be pdf first, then the other file.
then something like
find /
*might* work as well. I didn't check the syntax or results, so consult the man pages as necessary.
regarding your dec 20 post....yes, I read it. It seems we have our wires slightly crossed.
The statement " cannot test on the time to see if the file is currently being accessed (as I have to wait until the file is being accessed to delete it)." is closer to what I'm asking, so lets try again...
I'm looking for a description like: I have a
What I'm looking for is "
The method you've been talking about (waiting to delete until the file is accessed) has lots of potential pitfalls...for example: what does your process do if the file isn't opened in a timely fashion (i.e. user walks away, closes window or whatever)? Does it hang there waiting???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-24-2007 11:41 AM
тАО12-24-2007 11:41 AM
Re: How can I know that a file is being accessed ?
Sounds to me that all you need to know is whether it has been accessed.
Perhaps you can 'stat' the file and look for st_atime /* Time of last access */ being more recent than st_mtime /* Last modification time */.
IN perl you would use the "-X" file functions for those.
Unfinished perl code:
foreach (<*.rpt>) {
unlink if (-M > 1) || (-A < -M);
}
That is pick up a file to test in $_
If older then a day (1) delete.
If access less that modify then delete.
Below the signature some example values to explain. Note, the small (recent) time values are express with a float and 10 ** -5, as 1 second is 1/86400 :
$ perl -le 'print 1/86400'
1.15740740740741e-05
hth,
Hein.
$ cat > /tmp/x
aap
noot
mies
$ perl -e '$_ = shift; print -M, "\n", -A, "\n", -C , "\n"' /tmp/x
0.000162037037037037
0.000219907407407407
0.000162037037037037
$ perl -e '$_ = shift; print -M, "\n", -A, "\n", -C , "\n"' /tmp/x
0.000243055555555556
0.000300925925925926
0.000243055555555556
$ cat /tmp/x
aap
noot
mies
$ perl -e '$_ = shift; print -M, "\n", -A, "\n", -C , "\n"' /tmp/x
0.000509259259259259
8.10185185185185e-05
0.000509259259259259
$ chmod +r /tmp/x
$ perl -e '$_ = shift; print -M, "\n", -A, "\n", -C , "\n"' /tmp/x
0.000798611111111111
0.00037037037037037
4.62962962962963e-05
$ cat >> /tmp/x
teun
vuur
$ perl -e '$_ = shift; print -M, "\n", -A, "\n", -C , "\n"' /tmp/x
5.78703703703704e-05
0.000960648148148148
5.78703703703704e-05
$ cat /tmp/x
aap
noot
mies
teun
vuur
$ perl -e '$_ = shift; print -M, "\n", -A, "\n", -C , "\n"' /tmp/x
0.000428240740740741
3.47222222222222e-05
0.000428240740740741
Perl help:
-M Script start time minus file modification time, in days.
-A Same for access time.
-C Same for inode change time (Unix, may differ for other platforms)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 01:42 AM
тАО12-26-2007 01:42 AM
Re: How can I know that a file is being accessed ?
I guess I can use the method given by Hein.
I will try to write a script that runs every minute or so and looks at all the files in a certain directory.
I don't know scripting in Perl very well, so I have an additional question.
How can I loop trough all the files in a directory (for example /mnt/beelden) and check them one by one if they can be deleted ?
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 05:45 AM
тАО12-26-2007 05:45 AM
Re: How can I know that a file is being accessed ?
Below a more complete example using perl.
Should be self explanatory
run as : perl clean.pl&
or eventually run in cron or such.
Groetjes,
Hein.
-------------------- clean.pl -------------
use warnings;
use strict;
my $stop=0;
my $total_deleted=0;
while ( ! $stop ) {
my $deleted=0;
foreach ( ) {
$stop++ if /stop/; # soft exit ?
my $modified = -M;
my $accessed = -A;
if (($modified > 1) # more than a day old?
|| ($accessed < $modified)) { # accessed after modification?
$deleted++;
unlink;
}
} # each file
$total_deleted += $deleted;
print "deleted $deleted.\n";
sleep 5 unless $stop;
} # main loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 05:49 AM
тАО12-26-2007 05:49 AM
SolutionHein.
------------------------ clean.pl ----------
use warnings;
use strict;
my $stop=0;
my $total_deleted=0;
while ( ! $stop ) {
my $deleted=0;
foreach ( ) {
$stop++ if /stop/; # soft exit
my $modified = -M;
my $accessed = -A;
if (($modified > 1) # more than a day old?
|| ($accessed < $modified)) { # accessed after modification?
$deleted++;
unlink;
}
} # each file
$total_deleted += $deleted;
print "deleted $deleted.\n";
sleep 5 unless $stop;
} # main loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-26-2007 06:45 AM
тАО12-26-2007 06:45 AM
Re: How can I know that a file is being accessed ?
this solves my case.
Best regards,
- « Previous
-
- 1
- 2
- Next »