YogiChordiya
YogiChordiya

Reputation: 46

PHP: How to get last execution time of a specific file?

In php how to get last execution time of a specific file? I am working on a plugin which is a cron job and I want its last execution time. how can i get it? Actually problem is suppose due to some problem my is not executed then how can I know what was it's last execution time.

Upvotes: 0

Views: 1039

Answers (2)

Lee
Lee

Reputation: 10603

Best option would be too use a database (a flat file database like a simple text file would be fine) and store the time so you can read it later.

But if thats not an option try using the fileatime(). It should work fine as long as your cron job is the only one accessing the file in question

http://www.php.net/manual/en/function.fileatime.php

Upvotes: 0

troelskn
troelskn

Reputation: 117477

You can log it somewhere. Otherwise that information isn't available.

Use microtime to get an accurate time measure.

Upvotes: 1

Related Questions