Problems with CRON running PHP scripts

AGBlee1970

Registered
Hello

I want to run some PHP automatically. I understand that I can use CRON/Lynx to achieve this.

Using this from the command line works:
/usr/local/bin/lynx http://127.0.0.1/php_libraries/myscript.php

But trying to run it via CRON fails, I get an error message about "Terminal Type unknown".

On another forum someone else had this problem, and a user recommended they use -source before the URL, so:
/usr/local/bin/lynx -source http://127.0.0.1/php_libraries/myscript.php

I have tried this and it works, but am not convinced it is the correct way to be doing things. If I understand correctly CRON doesn't have the right environment variables configured which is why this error occurs? So should this be fixed a different way or is the -source solving the problem?
 
-dump is the correct way to do this. lynx is an interactive program, and it wants to display the page in the terminal so you can scroll, highlight links, etc. cron has no terminal type set, because cron isn't run in a terminal. Because it's not being run in a terminal, lynx is not happy as running in a terminal is what it does. Now, what lynx -dump does, it runs and it just dumps the output of the page to stdout. It does not require any user interaction, nor does it require a terminal to be set. -source does the same thing, but -source dumps the raw HTML text to stdout, not the formated text.

Brian
 
You might have better luck with CURL also. That's how I've always invoked PHP scripts.
 
Back
Top