COPYTRUNCATE
文件另存后清空文件,保持文件inode不变。一般可用于大日志文件的交换等场景。
- SRC_FILE_PATH:被复制及清空的文件路径(必填)。
- DST_FILE_PATH:另存为的文件路径(选填),默认为:SRC_FILE_PATH后加年月日时分秒。
警告
由于“文件另存”和“清空文件”两个操作不是原子操作, 在“另存”和“清空”之间可能会有新插入的数据, 而清空时也会清掉这部分新插入的数据,
导致数据部分丢失。
安装
pip install copytruncate
命令帮助信息
E:\copytruncate>copytruncate --help
Usage: copytruncate [OPTIONS] SRC_FILE_PATH [DST_FILE_PATH]
文件另存后清空文件,保持文件inode不变。一般可用于大日志文件的交换等场景。
SRC_FILE_PATH:被复制及清空的文件路径(必填)。
DST_FILE_PATH:另存为的文件路径(选填),默认为:SRC_FILE_PATH后加年月日时分秒。
警告:
由于“文件另存”和“清空文件”两个操作不是原子操作, 在“另存”和“清空”之间可能会有新插入的数据, 而清空时也会清掉这部分新插入的数据,
导致数据部分丢失。
Options:
-v, --verbose Show how many bytes copied.
--help Show this message and exit.
使用案例
- 将a.txt内容复制到a.txt.backup文件中,并清空a.txt的内容。保持a.txt的inode不变,已经打开a.txt进行写入操作的程序,也不需要重新打开a.txt。
copytruncate a.txt a.txt.backup
- 将a.txt内容复制到a.txt.20190613092823文件(20190613092823时命令执行时的时间,这里只是用于举例)中,并清空a.txt的内容。保持a.txt的inode不变,已经打开a.txt进行写入操作的程序,也不需要重新打开a.txt。
copytruncate a.txt
Metadata
Release files for copytruncate 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| copytruncate-0.1.1.tar.gz | 2.9 kB | Without provenance | Details for copytruncate-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| copytruncate-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for copytruncate-0.1.1-py3-none-any.whl |
Total release size: 7.2 kB
Release files / copytruncate-0.1.1.tar.gz
| Download URL | copytruncate-0.1.1.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56f8039cbab1ba814a74fffa7ff8de2dce148452ec5448a50e1490f41346db0c
|
|
BLAKE2b-256 checksum How to use checksums |
b8b3434a80a531d177db06d86089599574915eda3457e32ba737da76fc1490e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / copytruncate-0.1.1-py3-none-any.whl
| Download URL | copytruncate-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
885edc61799de1532f6827a35c9780b6db9947275dec29f159ca7af587e946dc
|
|
BLAKE2b-256 checksum How to use checksums |
1fa1c2421446bf34e8a336fb150773bbbb5ea0999020f119dc4124ed0ed06bfb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for copytruncate 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.