开发者

Is there a way to see when a php script last ran?

I am looking to make a script that runs and uses the time stamp of the last time it ran as a parameter to retrieve results that have been updated since that time. We were thinking of creating a database table and having it 开发者_运维百科update that and then retrieve the date from there, but I was looking for any other approach that someone might suggest.


Using a database table to store the last run time is probably the easiest approach, especially if you already have that infrastructure in place. A nice thing about this method is that you can write the run time right before the script terminates, in case it runs for a long time and you do not want it to start up again too soon.

Alternatively you could either write a timestamp to file (which has it's own set of issues) or attempt to fish it out of a log file (for example, the web access log if the script is being run that way) but both of those seem harder.


This might work: http://us.php.net/manual/en/function.fileatime.php (pass it $_SERVER['SCRIPT_FILENAME'])


Your best result would be to store your last run time. You could do this in a database if you need historical information, or you can just have a file that stores it.

Depending on how you run the script, you may be able to see it in your logs, but storing it yourself will be easier.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜