-1

Hi I have a PHP script which I would like to run with a cron job on a server.

  1. The script includes many other files

  2. When I browse to the script in my browser it runs as expected however: the script generates about 20 files to stored on the server, however, it returns the last file as a download to the browser(it also stores the file).

Will running it with a cron job:

50 23  * * *      php /var/www/site/myscript.php

Give the same results? Will the returned file cause some problems with the server?

tread
  • 9,064
  • 16
  • 86
  • 149
  • 1
    "it does return 1 download" what you mean? Also if you do not show the script I think it's not easy to understand what you need –  May 31 '13 at 12:28
  • What I understand is that you try to run `myscript.php` from a browser and the browser downloads the script as a file instead of running it. If so, your web server is misconfigured and you must tell it to treat PHP files as executables. – rath May 31 '13 at 12:30
  • My apologies, the script generates multiple files and stores them on the server (+/- 20 files) however the browser downloads the last one(it is also stored)... – tread May 31 '13 at 12:32
  • you could do a check for browser OR commandline http://stackoverflow.com/questions/343557/how-to-distinguish-command-line-and-web-server-invocation and just output `OK` for commandline, instead of the file to download – Waygood May 31 '13 at 12:37

2 Answers2

1

If you are forcing a download in the browser with header() or similar, then it won't have any effect on the command line.

Antonio Madonna
  • 919
  • 1
  • 9
  • 18
0

It will never make any problem while running through cron job in server. It will return what you expect.

If you want to get any input to the file, you just pass in at the end of that execute line as

50 23  * * *      php /var/www/site/myscript.php inputValue1

and get that in your file as $argv[1]

Vinoth Babu
  • 6,476
  • 10
  • 33
  • 53