[英]Linux, check if a temporary file gets created then deleted
I am trying to debug a problem on my server with wkhtmltopdf on a Django application. 我正在尝试使用Django应用程序上的wkhtmltopdf调试服务器上的问题。
The command generated to run wkhtml is pointing at a file in /tmp/. 生成的运行wkhtml的命令指向/ tmp /中的文件。
wkhtmltopdf.sh --encoding utf8--quiet/tmp/wkhtmltopdffa46k_h8.html -
Is there an easy way to check if the file gets created in /tmp then deleted? 有没有简单的方法来检查文件是否在/ tmp中创建然后删除了? (As it isn't present after the web request has completed).
(由于网络请求完成后不存在)。
The tool to debug such things is called strace
. 调试这类事情的工具称为
strace
。 Run: 跑:
strace -f wkhtmltopdf.sh --encoding utf8--quiet/tmp/wkhtmltopdffa46k_h8.html
Explanation: 说明:
A program in order to create, write, close, delete a file needs to call kernel code in order to achieve that. 为了创建,写入,关闭,删除文件的程序需要调用内核代码才能实现。 This kernel functions are called system calls .
该内核函数称为系统调用 。
strace
will run the program and prints any system call the command makes to stderr(!). strace
将运行程序并打印命令对该stderr(!)进行的任何系统调用。
This might give you a little bit too much information if you read it unfiltered. 如果您未过滤阅读,可能会给您太多的信息。 If you want to
grep
for the filename of the tempfile, keep in mind that strace
writes to stderr: 如果要使用
grep
作为临时文件的文件名,请记住strace
写入stderr:
strace -f program ... 2>&1 | grep filename
PS: Alternatively inotifywait
from the package inotify-tools
can be used: PS:也可以使用
inotify-tools
包中的inotifywait
:
inotifywait -m --format "%e %f" /tmp
Better explained here: https://unix.stackexchange.com/a/164801/45365 更好的解释在这里: https : //unix.stackexchange.com/a/164801/45365
尝试使用
watch -n0,1 "ls -lrt /tmpdir/ | tail"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.