简体   繁体   English

如何使用 shell 脚本调用 PHP 脚本?

[英]How to invoke a PHP script using shell script?

I am setting a cron job on my linux server.我正在我的 linux 服务器上设置一个 cron 作业。

So i am writing a shell script for it,which invoke after every 20 minutes.所以我正在为它编写一个 shell 脚本,它每 20 分钟调用一次。

In this shell script i need to do following:在这个 shell 脚本中,我需要执行以下操作:

I want to executed a php script if something changed(in last 20 min) in mydata.csv file.如果 mydata.csv 文件中的某些内容发生变化(在过去 20 分钟内),我想执行 php 脚本。

So plese tell me how can i do this?所以请告诉我我该怎么做?

-Thanks -谢谢

  1. Check the last modified date on the CSV file and compare it to the current time (not on a *nix machine right now, Google it)检查 CSV 文件上的最后修改日期并将其与当前时间进行比较(现在不在 *nix 机器上,谷歌它)
  2. Execute the PHP script执行 PHP 脚本

    /usr/bin/php /path/to/php/script.php

Disclaimer: The path to your PHP binary may differ免责声明:PHP 二进制文件的路径可能不同

Also see http://www.linuxforums.org/forum/programming-scripting/107278-how-prgrammatically-compare-file-timestamp-against-currrent-time.html另见http://www.linuxforums.org/forum/programming-scripting/107278-how-prgrammatically-compare-file-timestamp-against-current-time.html

just call php from it只需从中调用 php

php myScript.php

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

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