0

I am setting a cron job on my linux server.

So i am writing a shell script for it,which invoke after every 20 minutes.

In this shell script i need to do following:

I want to executed a php script if something changed(in last 20 min) in mydata.csv file.

So plese tell me how can i do this?

-Thanks

3
  • You want to check if the file changed and then execute the php script, or just execute the php script every 20 minutes? You can just run 'php path/to/file.php' to execute a php file in shell. Commented Aug 10, 2011 at 6:08
  • i want if the file changes then execute php script Commented Aug 10, 2011 at 6:09
  • i think i can do it in a other way also that execute php after every 20 min then check the file changes then do some stuff otherwise not.But please suggest me how can i do this in a php?if you hope this is also a correct way Commented Aug 10, 2011 at 6:11

2 Answers 2

3
  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)
  2. Execute the PHP script

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

Disclaimer: The path to your PHP binary may differ

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

Sign up to request clarification or add additional context in comments.

1 Comment

thanks i got your point but still i have a query:stat -c "%y" file this will return me something like this "2011-08-10 11:36:48.000000000 +0530" and date +%s -d '20 minute ago' will give like this:1312956839 and i know that 20*60=1200 sec in 20 minutes but plz tell me how can i compare that file has been modified or not ?
0

just call php from it

php myScript.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.