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
asked Aug 10, 2011 at 6:03
Peeyush
4,90817 gold badges67 silver badges93 bronze badges
-
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.Pelshoff– Pelshoff2011年08月10日 06:08:06 +00:00Commented Aug 10, 2011 at 6:08
-
i want if the file changes then execute php scriptPeeyush– Peeyush2011年08月10日 06:09:29 +00:00Commented 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 wayPeeyush– Peeyush2011年08月10日 06:11:18 +00:00Commented Aug 10, 2011 at 6:11
2 Answers 2
- 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)
Execute the PHP script
/usr/bin/php /path/to/php/script.php
Disclaimer: The path to your PHP binary may differ
answered Aug 10, 2011 at 6:08
Phil
166k25 gold badges265 silver badges269 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Peeyush
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 ?
just call php from it
php myScript.php
Comments
default