开发者

Clean exit when killing a PHP cron

I'm running several PHP cron jobs, which are running transactional updates on the disk. By transactional, I mean that several updates to the filesystem need to be either all committed together to the filesystem, or none committed, same concept as for a database transaction.

I have no technical way to enforce this filesystem transaction (any pointer would be appreciated on this point though), so I rely on my PHP cr开发者_如何学编程on job to properly group these updates.

However, sometimes I need to kill a long-running cron job (with Control-C), and I'd like to break my script at a safe breakpoint.

When programming for a web application, I use a combination of ignore_user_abort() and connection_aborted(), so I'm looking for the same kind of solution for command-line applications:

Is it possible to catch the kill signal, and to exit only when a safe point is reached?


Take a look at http://www.php.net/manual/en/function.pcntl-signal.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜