linux哪些文件被更新,Linux:如何確定文件是否已被其他進程更新?

news/2024/7/3 17:09:38

6

John mentioned the two main routes you can take for watching files under Unix/Linux systems: notification and polling.

John提到了在Unix / Linux系統下觀看文件可以采取的兩條主要途徑:通知和輪詢。

Notification is when the system itself (usually the kernel) triggers a message to registered applications whenever the file is accessed or written to. This approach requires a compliant system and might not be available on older machines.

通知是指系統本身(通常是內核)在訪問或寫入文件時向注冊的應用程序發出消息的時間。此方法需要兼容的系統,並且可能在舊機器上不可用。

The primary implementation of notification under Linux is inotify, which is built into kernels 2.6.13 and later and can be patched into 2.6.12 and earlier. There's a nice IBM guide on using inotify as well as a basic set of tools and C library for accessing inotify.

Linux下通知的主要實現是inotify,它內置於2.6.13及更高版本的內核中,可以修補到2.6.12及更早版本。有一個很好的IBM指南,使用inotify以及一組基本工具和C庫來訪問inotify。

Polling is when your program repeatedly checks a file at intervals to see if anything about that file - its size, last modification time, owner, etc. - has been changed.

輪詢是指您的程序每隔一段時間重復檢查一次文件,以查看該文件的任何內容 - 其大小,上次修改時間,所有者等 - 是否已更改。

There's no standard implementation of this, as it's written on a program-level rather than system-level basis, although the system call poll exists and seems to do something useful for this purpose (the man page says it's similar to select, and it waits for an event to become available on a file descriptor). You could also take the more basic approach with stat and do your checking on your own.

沒有標准的實現,因為它是在程序級而不是系統級的基礎上編寫的,盡管系統調用輪詢存在並且似乎為此目的做了一些有用的事情(手冊頁說它類似於select,它等待使事件在文件描述符上可用)。您還可以使用stat的更基本方法並自行進行檢查。


http://lihuaxi.xjx100.cn/news/242407.html

相关文章

Python os库的使用

1. 基本介绍 os提供通用的、基本的操作系统交互功能 os库是Python的标准库,提供几百个处理函数 常用有路径操作、进程管理、环境参数等几类 路径操作:os.path子库,处理文件路径及信息 进程管理:启动系统中其他程序 环境参数&…

测试我的第一个随笔

# encodingutf-8## Python Version 3.5# 利用数学中的复数 求解 一元一次方程(从网上看来的)def solve(qx, var): qx qx.replace(, -() ) c eval(qx , {var: 1j}) return -c.real/c.imagres solve(2*x 4 8,x)print(res)转载于:https://www.cnblogs.com/imyjy/p/…

UI设计培训分享:UI设计的职业发展路径

UI设计师这个岗位也是分等级的,有初、中、高级区别,想要在UI设计这个行业站稳脚跟,那么一定要为一名合格的高级UI设计师,下面小编就为大家详细的介绍一下UI设计的职业发展路径。 UI设计培训分享:UI设计的职业发展路径&…

ITFriend站点内測公測感悟

4月份做出站点Demo。就開始让用户使用了。最初的黄色版界面。被吐槽得比較厉害。关于界面。每一个人都有自己的看法,仅仅是喜欢和不喜欢的人比例不一样。后来。花3400元请了个设计师,设计了一套界面。总体效果令人惬意,一些细节也是被非常多用…

Python在linux服务器上解压,python3传文件到linux服务器然后解压

运维开发网 https://www.qedev.com2020-07-09 10:40出处:网络作者:运维开发网整理#!/usr/bin/env python# -*- coding:utf-8 -*-import osimport paramikoimport timefrom scp import SCPClient相关专题:#!/usr/bin/env python# -*- coding:u…

Python 第三方库自动安装脚本

需求:批量安装第三方库需要人工干预,能否自动安装? 现假设我们要安装以下库 #BatchInstall.py import os libs {"numpy","matplotlib","pillow","sklearn","requests",\ "jie…

UI设计培训分享:设计当中的颜色运用

参加UI设计培训的同学应该都知道,颜色的搭配是学习UI设计非常重要的一步,颜色跟其他的东西一样,适量才会运用得当,如果在你的配色计划中坚持使用马克思三原色的话,你会得到更好的配色结果,为一个项目配色时…

Cross-validation

2019独角兽企业重金招聘Python工程师标准>>> 1: Introduction To Validation So far, weve been evaluating accuracy of trained models on the data the model was trained on. While this is an essential first step, this doesnt tell us much about how well …