executing php from shell

Posted on 2009-04-29
Last Modified: 2013-12-12
which one execute a php script fast?
a) shell using php -f script.php
b) using http as

the script does a lots of database inserts and take lot of time to execute
which method gives less load to the server?
thanks in advance
Question by:sree01
    LVL 7

    Accepted Solution


    The first method is faster.

    LVL 5

    Assisted Solution

    I thinks method a). But I don't think it will make a big difference.

    To improve your script performance you will have to work on sql queries

    you can also nice your process

    nice 'php -f script.php' 10 &  

    This will give a low priority to your script an give more system ressource to other applications.
    You can go to up to 20 as Parameter value.
    LVL 14

    Assisted Solution


    The first method is little bit faster.

    And follow the link below to speed up your php script:

    LVL 2

    Assisted Solution

    The shell will run with slightly less resource usage.
    If your script takes an excessive time to execute, you may receive a timeout by accessing it through the web server without a timeout change.

    If your script does not take any input, variables, etc.., you should probably consider just dumping the table to a text file and execute it through the sql client. That is unless you do not have access to the client or you need it to be as simple as possible.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now