954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP with Javascript in cron

Hi,

I have PHP script which is calculating some Google Maps API functions in Javascript and then sending output back to PHP.

My biggest problem is, that i need it to run at intervals, but AFAIK cron can't handle javascript

I've tried a little workaround - setting cron which sends the url to online web thumbnail generator - and it works. Until this online service denied loading scripts at their side.

It must be some way to achieve this. Maybe running some instance of browser in PHP?

palsoft
Newbie Poster
5 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

There is no direct/good way. You have to run you code in a browser somehow. Maybe if your server allows, save the output in file and run "firefox file.htm".

Also, in Windows I think you can get your work done using PHP and COM components. But again a lot is dependent upon your host. If you have your own server or have good control, maybe you can get what you want.

vishesh
Nearly a Posting Virtuoso
1,381 posts since Oct 2006
Reputation Points: 85
Solved Threads: 42
 

Or maybe there's some online service allowing to run a webpage like one that i was using (thumbalizr.com). Does anyone know?

palsoft
Newbie Poster
5 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

You can use cron to call a php page.
IN your crontab file, the command part would be something like this:

/usr/bin/php /users/me/www/myfile.php
edwinhermann
Junior Poster
141 posts since Sep 2009
Reputation Points: 67
Solved Threads: 29
 

You can use cron to call a php page. IN your crontab file, the command part would be something like this:

/usr/bin/php /users/me/www/myfile.php

Cron can not run client-side Javascript...

palsoft
Newbie Poster
5 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

Perhaps a site uptime checking service.

Or if you have a pc running 24/7, open the page in Opera and set it to refresh at your interval.

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Thank you very much, pritaeas! I've managed it by running it thru http://pagespeed.googlelabs.com/ :)

palsoft
Newbie Poster
5 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: