centos文件锁定解锁

If you try to update certain Windows files (such as programs or word documents) while they are in use, you get the the standard “access denied, file is in use” error. While the reasoning behind this is obvious, it can be quite annoying if you need to update a small executable which is currently in use by another user. In these situations, you have, among others, the following choices, all of which take up your valuable time:

如果在使用某些Windows文件(例如程序或Word文档)时尝试对其进行更新,则会出现标准的“访问被拒绝,文件正在使用”错误。 尽管背后的原因很明显,但是如果您需要更新另一个用户当前正在使用的小型可执行文件,可能会很烦人。 在这些情况下,您可以选择以下选项,所有这些都会占用您宝贵的时间:

  • Track down and contact the users who are currently using the file, tell them to close out/save their work, etc. and then apply the update. 跟踪并联系当前正在使用该文件的用户,告诉他们关闭/保存其工作等,然后应用更新。
  • Don’t apply the update immediately and just remember to do it later when users are not in the system. 不要立即应用此更新,只是记得当用户不在系统中时稍后再进行更新。
  • Schedule some utility to replace it at the next reboot.安排一些实用程序以在下次重新启动时替换它。

Well, we have another solution available for you: a script you invoke via the Send To menu which does the following:

好了,我们还有另一种解决方案供您使用:您通过“发送至”菜单调用的脚本执行以下操作:

  1. Tries to delete the old file. 尝试删除旧文件。
  2. If the old file is locked, the script waits 20 seconds. Go to step 1. 如果旧文件被锁定,脚本将等待20秒。 转到步骤1。
  3. If the old file is not locked, the old file is replaced with the new file. Go to step 4. 如果旧文件未锁定,则将旧文件替换为新文件。 转到步骤4。
  4. Optionally log off once the process is done.(可选)完成该过程后注销。

This way, you get just get the replace command in motion and the script takes care of the rest. This can help you avoid tracking down users or having to install unnecessary utilities on your system.

这样,您就可以直接使用replace命令,脚本将处理其余的工作。 这可以帮助您避免追查用户或避免在系统上安装不必要的实用程序。

设置和使用 (Setup and Usage)

The script can be placed anywhere on your system. Then all you need to do is create a shortcut to it in your SendTo folder:

该脚本可以放在系统上的任何位置。 然后,您所需要做的就是在SendTo文件夹中为其创建一个快捷方式:

To start the replace process, select the old file and new file and then invoke the Send To option by right clicking on the old file/file to replace.

要开始替换过程,请选择旧文件和新文件,然后通过右键单击要替换旧文件/文件来调用“发送到”选项。

The script will display exactly what will happen and present you with the option to be logged off once the replace is completed.

该脚本将准确显示将要发生的情况,并为您提供替换完成后注销的选项。

The script will continuously try to delete the old file while waiting several seconds in between tries.

该脚本将在尝试之间等待几秒钟的同时不断尝试删除旧文件。

All you have to do is get the process running and whenever all your users are out, the file will be replaced.

您所要做的就是使该流程运行,并且只要您的所有用户都在外,该文件就会被替换。

保障措施 (Safeguards)

The script has a couple of built in safeguards:

该脚本有两个内置的防护措​​施:

  • The old file and new file are clearly presented so you know exactly what will happen.清楚地显示了旧文件和新文件,因此您确切知道会发生什么。
  • You can close the command window at any time to stop the action (of course, assuming the replace has not been performed already).您可以随时关闭命令窗口以停止操作(当然,假设尚未执行替换操作)。
  • The script will ensure you have selected only two files when you invoke the Send To command. If you select, for example, 1 or 3 files you will receive a notice message and nothing will happen.该脚本将确保您在调用“发送到”命令时仅选择了两个文件。 例如,如果您选择1或3个文件,您将收到一条通知消息,什么也不会发生。

剧本 (The Script)

@ECHO OFF
TITLE Replace Locked File
ECHO Replace Locked File
ECHO Written by: Jason Faulkner
ECHO SysadminGeek.com
ECHO.
ECHO.SETLOCAL EnableExtensionsREM Validation.
SET Error=1
IF {%2}=={} (ECHO Two files must be selected to run the replace.GOTO End
)
IF NOT {%3}=={} (ECHO More than 2 files were selected so I am not sure what to do.GOTO End
)SET Error=0
SET OldFile="%~f1"
SET NewFile="%~f2"
SET LogOffWhenDone=0REM Show what will happen so you have a chance to cancel out.
ECHO Old File: %OldFile%
ECHO ---------
ECHO New File: %NewFile%
ECHO.
ECHO You can cancel replacing the Old File with the New File by closing now.
ECHO.REM Log off prompt. If you do not want to see this, you can delete these lines.
ECHO Automatically log off once the replace process has completed?
ECHO Enter 'Y' to automatically log off or enter anything else to not.
SET /P LogOffWhenDone=:DoReplace
DEL /F /Q %OldFile%
IF NOT EXIST %OldFile% (MOVE %NewFile% %OldFile%ECHO File replaced successfully.GOTO End
)
ECHO.
ECHO The Old File is still locked. Waiting a few moments to try again.
TIMEOUT /T 20
GOTO DoReplace:End
IF {%Error%}=={1} (ECHO Instructions for use:ECHO 1. Select the two files in Windows Explorer.ECHO 2. Right click on the Old File and go Send To - Replace Locked FileECHO.ECHO The file you right clicked on will be replaced with the other selected file.ECHO.ECHO Stopping without doing anything. Press any key to close.TIMEOUT /T 15
)
IF /I {%LogOffWhenDone%}=={Y} (ECHO.ECHO Option to Log Off when completed was selected.ECHO You will be logged off shortly.SHUTDOWN /L
)
ENDLOCAL

链接(Links)

Download ReplaceFile Script from SysadminGeek.com

从SysadminGeek.com下载ReplaceFile脚本

翻译自: https://www.howtogeek.com/51138/easily-replace-a-locked-file-once-it-becomes-unlocked/

centos文件锁定解锁

centos文件锁定解锁_解锁后轻松替换锁定的文件相关推荐

  1. python移动文件的函数_移动并重命名2000个文件,用Python,只需3秒

    原标题:移动并重命名2000个文件,用Python,只需3秒 作者:陈熹.刘早起 来源:早起Python 今天介绍的案例是如何利用Python来 自动化移动.修改.重命名文件/夹,这样的操作在日常办公 ...

  2. linux 再文件夹目录下,批量替换文件名、文件内容字符串

    基本使用命令 sed -i 's/<原字符串>/<替换字符串>/g' <文件> grep -rl "<搜索字符串>" find -n ...

  3. mysql启用登陆失败锁定账号_登陆失败账号锁定

    /*** 移出非安全登录记录 * *@paramindex_*/ private voidremoveJPTLoginSecurity(String ip, String loginKey) {//移 ...

  4. 手机pdf文件转语音_职场小白不懂PDF文件转Word文档?试试微软的这款APP吧

    在互联网时代,工具就是生产力.熟练掌握各种工具软件,就可以让你的工作效率成倍提升.而PDF转Word功能,对于文案工作者而言,也是一个超级实用.必须Get到的技能.如何理解呢?来来来,先给大家说一个职 ...

  5. 多个python文件相互调用_用 python提取两个文件之间的内容

    我有两个文件: 一个文件叫exemple_data.csv 里面包含3个id,每个id一行 ZINC04203483 ZINC26895155 ZINC03651026 一个文件叫exemple.sd ...

  6. 上传文件白名单_十大常见web漏洞——文件上传漏洞

    漏洞介绍 在我们浏览网页时,文件上传是非常常见的,比如我们会上传头像.附件.视频等文件,文件上传漏洞通常由于网页代码中的文件上传路径变量过滤不严造成的,如果文件上传功能实现代码没有严格限制用户上传的文 ...

  7. oracle .dbf文件过大_学习这篇Oracle数据库文件坏块损坏的恢复方法,拓展你的知识面...

    一.Oracle数据库系统简介: ORACLE数据库系统是美国ORACLE公司(甲骨文)提供的以分布式数据库为核心的一组软件产品,是目前最流行的客户/服务器(CLIENT/SERVER)或B/S体系结 ...

  8. 在linux中的文件中查找_如何在Linux中查找文件

    在linux中的文件中查找 如果您是Windows用户或OSX的非超级用户,则可能使用GUI查找文件. 您可能还会发现界面有限,令人沮丧或两者兼而有之,并且学会了精于组织事物并记住文件的确切顺序. 您 ...

  9. file对象怎样获取文件的长度?_使用FSO对象获取整个文件夹的信息

    大家好,我们今日讲解"VBA信息获取与处理"教程中第十八个专题"FSO对象对文件及文件夹的处理"的第三节"使用FSO对象获取整个文件夹的信息" ...

  10. sudo修改文件夹名字_用 Python 高效智能管理文件夹

    #「闪光时刻」主题征文 二期# 大家在写报告.写总结时,是否会先去翻一下以前写过的类似的东西?是否有看过比较好的文章,想保存时却为归类而纠结?是否电脑里的文件越来越多,想删掉一些却又舍不得?身处大数据 ...

最新文章

  1. php 生成器 教程,PHP扩展生成器_PHP教程
  2. 关于浮点数的误差理解
  3. Angular [(ngModel)]的ng-dirty设置时机
  4. POJ3096Surprising Strings(map)
  5. Asp.net mvc 知多少(六)
  6. 作者:海沫,女,博士,中央财经大学信息学院副教授,CCF高级会员。
  7. akka一些邮箱的实现
  8. Java通讯录管理系统使用线性表任务台程序
  9. perl 如何判断变量为空
  10. WinRAR命令行参数整理
  11. 服装计算机辅助设计论文,计算机辅助高校服装设计论文
  12. oracle客户端 PLSQL安装配置教程
  13. 在J.U.C多线程中,AQS维护这一个CLH同步队列,这个队列遵循着FIFO原则
  14. 读浅墨博客 十一 笔记
  15. html5妇女节游戏,html5开发三八女王节表白神器
  16. 自然语言处理核心期刊_中国中文信息学会
  17. 抓包导出的har格式解析
  18. 计算机科学导论(5):计算机网络
  19. wireless communications in smart grid 2
  20. 手把手教你使用curl2py自动构造爬虫代码并进行网络爬虫

热门文章

  1. php网站渗透实战_PHP网站安全-漏洞渗透及解决方式—概述
  2. 矩阵理论——正交变换
  3. 14串聚合物锂电池保护板和电路图(带均衡功能)
  4. PyQt5 与PyQt4的区别
  5. win10安装lr11
  6. 关于3CDaemon的FTP服务端异常
  7. mysql 建数据库命令_新手入门MySQL数据库命令大全
  8. java分布式特点_java分布式架构是什么?分布式架构的优缺点有哪些?
  9. java nlpir_NLPIR爱好者
  10. 数据分析5大软件Excel、SAS、R、SPSS、Python优势分析