简体   繁体   English

清理 Perl 脚本不应删除符号链接到的目录

[英]Cleanup Perl script should not delete a directory that is symlinked to

A cleanup Perl script running periodically deletes old log files, and if the folder is empty, it deletes the folder as well.定期运行的清理 Perl 脚本会删除旧的日志文件,如果文件夹为空,它也会删除该文件夹。 Unfortunately, there is one exception: it should not delete a directory that is symlinked to.不幸的是,有一个例外:它不应该删除符号链接到的目录。

There's no way to tell if there exists a symlink that directly references a dir.无法判断是否存在直接引用目录的符号链接。 (Same for indirect references.) (间接引用也一样。)

The best you could do is check every single file on the entire file system, but even that monumental effort wouldn't be perfect.您可以做的最好的事情是检查整个文件系统上的每个文件,但即使是巨大的努力也不是完美的。 For example, it won't find symlinks on devices that aren't currently mounted, it won't find foreign symlinks to shared portions of the file system, etc.例如,它不会在当前未安装的设备上找到符号链接,它不会找到指向文件系统共享部分的外部符号链接等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM