Koozali.org: home of the SME Server

Can I create a cronjob that executes external PHP script?

Offline weblance

  • ****
  • 95
  • +0/-0
Can I create a cronjob that executes external PHP script?
« on: March 24, 2011, 01:49:24 PM »
Is ti possible to create a cronjob on the SME that executes an external PHP script once every hour? If yes, how?

/Carl

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #1 on: March 24, 2011, 01:55:31 PM »
please, define "external"

php has a cli too

Offline weblance

  • ****
  • 95
  • +0/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #2 on: March 24, 2011, 02:28:27 PM »

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #3 on: March 24, 2011, 02:40:43 PM »
a script that use wget or curl in cron.d or crontab should do what you need..

do you expect to send parameters? do you need to get any result?

Offline weblance

  • ****
  • 95
  • +0/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #4 on: June 16, 2011, 11:42:31 PM »
Sorry for the late reply.

I do not need to send any parameter and i don't get a result. I only need to run a script on a remote server. Is there a timeout? What I mean is that the remote script can take several minutes to excute.

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #5 on: June 17, 2011, 12:06:53 AM »
Sorry for the late reply.

I do not need to send any parameter and i don't get a result. I only need to run a script on a remote server. Is there a timeout? What I mean is that the remote script can take several minutes to excute.


wget is your friend :-)
man wget for more details

Offline weblance

  • ****
  • 95
  • +0/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #6 on: June 17, 2011, 12:13:41 AM »
Thank you very much!

I'll check wget out. What about execution time, is there a limit? The script can take several minutes to complete...

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #7 on: June 17, 2011, 10:44:41 AM »
I'll check wget out. What about execution time, is there a limit? The script can take several minutes to complete...

read the man page, you'll find the answer

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Can I create a cronjob that executes external PHP script?
« Reply #8 on: June 17, 2011, 04:24:32 PM »
The script can take several minutes to complete...

Most web browsers and most web servers won't allow it to complete if it takes that long.

Offline Jean-Philippe Pialasse

  • *
  • 2,912
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Can I create a cronjob that executes external PHP script?
« Reply #9 on: June 23, 2011, 07:14:06 AM »
the problem with timeout can be avoid on the webserver side using the comand set time limit in the loop (i guess there is some loop in it ;)
each time it will set the timeout it will be reseted to 0 ... set a timeout value for one pass in the loop ( 10 seconds per pass should be enough)

http://php.net/manual/en/function.set-time-limit.php

usually the timeout is 30 second to complete all the script
« Last Edit: June 23, 2011, 07:16:01 AM by unnilennium »