bobinindia Posted May 18, 2008 Share Posted May 18, 2008 I want to run a php script as a cron job on my local machine. I don't get the path system. If my php file is in applications as it is with MAMP what is the path to execute the script with cron? OS X tiger. Very simple I suspect. Quote Link to comment Share on other sites More sharing options...
marklarah Posted May 18, 2008 Share Posted May 18, 2008 Well I use MAMP as well. First, get leopard ;). Second, you need to play around doing something in terminal... This is more a unix issue, so I suggest you move this topic to the relevant board unless someone knows more than I. Try google though. Quote Link to comment Share on other sites More sharing options...
marklarah Posted May 18, 2008 Share Posted May 18, 2008 unless this helps: http://www.macdevcenter.com/pub/a/mac/2001/12/14/terminal_one.html?page=2 Quote Link to comment Share on other sites More sharing options...
bobinindia Posted May 18, 2008 Author Share Posted May 18, 2008 I have been googling all day. I am sure it is sooo simple. I have a script at http://localhost:8888/process/testing/onetime.php I want it to run as a cron job. 10 1 * * * /usr/bin/wget -q localhost:8888/process/testing/onetime.php What is wrong with this. Is there some path info missing or something else Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted May 18, 2008 Share Posted May 18, 2008 Is there some path info missing or something else Yes, localhost:8888 is not part of any filesystem path. I don't use MAMP so I'm not sure where exactly your servers root documents are stored, one way you could find out would be to write a php script with the following in it. <?php echo $_SERVER['DOCUMENT_ROOT']; ?> from there you just append to ten of the path. eg; If you can access your script via http://localhost:8888/process/testing/onetime.php in your browser, and the above $_SERVER['DOCUMENT_ROOT'] prints /var/www/ then your path would be... /var/www/process/testing/onetime.php Quote Link to comment Share on other sites More sharing options...
bobinindia Posted May 18, 2008 Author Share Posted May 18, 2008 the root is /Applications/MAMP/htdocs so i made my cron 06 * * * * /usr/bin/wget -q /Applications/MAMP/htdocs/process/testing/onetime.php and nothing happened. ??? Quote Link to comment Share on other sites More sharing options...
trq Posted May 18, 2008 Share Posted May 18, 2008 and nothing happened How do you know? What exactly does the script do? Have you checked your cron logs? Quote Link to comment Share on other sites More sharing options...
bobinindia Posted May 18, 2008 Author Share Posted May 18, 2008 Nothing happens is sure as i know the script works when i open it in my browser, It runs a thumbnail script since you asked. The problem must be the path to the script or my cron syntax. Also how do you see the logs for cron? Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted May 18, 2008 Share Posted May 18, 2008 The problem (didn't notice it before) is your calling the script with wget. You need to call it with php. 06 * * * * /usr/bin/php /Applications/MAMP/htdocs/process/testing/onetime.php Otherwise, if it needs to be executed via the server you can call it with wget, but wget expects a url. eg; 06 * * * * /usr/bin/wget -q http://localhost:8888/process/testing/onetime.php Quote Link to comment Share on other sites More sharing options...
bobinindia Posted May 18, 2008 Author Share Posted May 18, 2008 Still no luck trying both those lines. This is what is in the crontab: # The periodic and atrun jobs have moved to launchd jobs # See /System/Library/LaunchDaemons # # minute hour mday month wday who command 08 * * * * /usr/bin/wget -q http://localhost:8888/process/testing/onetime.php Nothing else. Maybe I have to do it somewhere else though it is meant to still work in Tiger. We might be moving away from a php issue here. Quote Link to comment Share on other sites More sharing options...
trq Posted May 18, 2008 Share Posted May 18, 2008 Yeah, I'de say weve gone way out of the realm og it being a php issue. You have waited until the 8th minute of each hour? Quote Link to comment Share on other sites More sharing options...
bobinindia Posted May 18, 2008 Author Share Posted May 18, 2008 i change that each time i try for a couple of minutes ahead. I am stupid but... Quote Link to comment Share on other sites More sharing options...
bobinindia Posted May 19, 2008 Author Share Posted May 19, 2008 simply needed to rebuild the cron by issueing crontab /etc/crontab from the command line after altering the cron. Thanks for all the thoughts Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.