Thanks to these forums I have managed to get my PHP script to run as a cron job using LYNX to execute it.

The problem I have now (and I can't seem to find any solution in the forums) is that the LYNX process never dies - it just sits there.

Have I missed something here? Anyone sorted this out? I saw an old post that said someone got abuse for "overloading" their server with these dead processes and I don't want to get the same fate!

By the way, I would prefer NOT to run a second cron job to kill the first just in case it has not fully completed before getting killed!

Thanks
Richard

    The trick is that whenever you launch lynx, it actually starts a web-browser, waiting for user input.. wich is generally a bad idea 😉 Lynx has a very nice -dump option, e.g.:

    lynx -dump http://www.phpbuilder.com

    This dumps the rendered output of www.phpbuilder.com to stdout. You should use this option, and if your script outputs some sort of result, error messages etc, you should cat the rendered page on to a log file. Otherwise, if the data outputted is void, send it to 'the black hole'! E.g.:

    lynx -dump http://your.website.com >> /some/dir/cronlog

    or;

    lynx -dump http://your.website.com > /dev/null

      Why don't you use wget instead of lynx? It's not a browser, it's a tool to get a page, desinged to get the page and exit.

      Sounds like it's the better tool for the job.

      --Kurt

        Suggestion:

        Why don't you use Perl?
        Its syntax it's very much like PHP.

          Why not just use a crontab to call php directly:

          47 20 * /path/to/php -q /path/to/script.php > /dev/null

          This example runs script.php at 8:47pm every day and dumps any output to the garbage.

          Rob

            Thanks for all the ideas and advice.

            I've gone for the "lynx -dump ..." suggestion mainly because it does the business for me but also I don't have wget and I can't use PHP other than as an Apache module.

            No problem though because it all seems to be okay.

            Thanks again
            Richard

              2 months later

              This works great. I banged my head around about 2 days and finally realised this works for me when PHP is installed as an API under apache.

                17 days later

                10 05 * wget -q --spider host.domain.com/script1.php

                /dev/null

                  Write a Reply...