写入锁定的文件,无论锁定状态 [英] Write to locked file regardless of lock status

查看:139
本文介绍了写入锁定的文件,无论锁定状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有写锁定的文件的方式,无论什么程序/进程把它打开?

Is there a way to write to a locked file regardless of what program/process has it open?

情景:


  • 作为服务运行一个商业产品,锁定一个日志文件。

  • 服务不能被停止,因为它会影响客户。

  • 想在文件作为标记年底注入一行。

获取错误:因为它正在被其他进程使用进程无法访问文件

Getting error: The process cannot access the file because it is being used by another process.

有没有追加的锁定文件中的行什么办法?

Is there ANY way to append a line on a locked file?

此外,怕打破锁定状态,因为这可能会导致商业计划打破。

Also, afraid of breaking the lock status, as it may cause the commercial program to break.

本来以为批处理文件,直到找出日志文件被锁定。会做的PowerShell或任何语言可以拉动这一关。

Originally thinking batch file until finding out log file is locked. Will do powershell or whatever language can pull this off.

推荐答案

后,锁(ED)文件的整体思路是,有锁的过程中不必担心其他进程修改该文件,所以锁的拥有者不具备查询文件系统中所有的时间,可以做它的操作更有效。结果
而看到大卫·施瓦茨和肯白

No, the whole idea of the lock(ed) file is that the process that has the lock does not have to worry about other processes modifying the file, so the lock owner does not have to query the file system all the time and can do it's operations much more efficiently.
And see earlier comments by "David Schwartz" and "Ken White"

这篇关于写入锁定的文件,无论锁定状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆