Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2002
    Posts
    3,729

    Help with running bg processes

    Hello,

    I have a php script that I run via command line interface(CLI).

    I start the script using a command like the following via command line:

    Code:
    php script.php 1 database&
    The script starts fine and does what it's supposed to do.

    I see the output of the script on my screen. What it does is basically download a certain file every 10 minutes, parse the data in the file and slot it into a database.

    Now how would i get out of that screen *without* ending the process? Nothing seems to work.

    As soon as i close the shell, the process seems to end. If i try to hit [enter] a couple of times and quickly squeeze in the word "logout", true enough the bash prompt will disappear *but* the screen remains as it is. I assume that bash is waiting for the php script to finish execution. Problem is, it never will.

    Could someone please help me out here? I'm in a fix. :/

    Thank you.
    Have you Floble'd today?

  2. #2
    Join Date
    Feb 2002
    Posts
    3,729
    By the way, i need to get out of the screen which contains the output of the php script, so that i'm able to either:

    1) Get out of the shell alltogether

    2) Execute other commands via bash

    Currently it doesn't let me do any of the above. I have no choice but to stare at the output of the script.
    Have you Floble'd today?

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    465
    nohup command & should work

  4. #4
    Join Date
    Feb 2002
    Posts
    3,729
    I don't understand you Karthick?

    Do i open up another shell window? What exactly should i type?
    Have you Floble'd today?

  5. #5
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,460

  6. #6
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    465
    The & itself should run the process in the background. Example:

    Code:
    yum list > yum.list &
    So try:

    Code:
    nohup php script.php 1 database &
    or:

    Code:
    php script.php 1 database > somefile &

  7. #7
    Join Date
    Feb 2002
    Posts
    3,729
    Thank you.

    I used that command and it seems to work.

    What do i do if i want to resume the viewing of the script's output?
    Have you Floble'd today?

  8. #8
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    465
    If you used nohup, then

    Code:
    cat nohup.out
    Code:
    tail nohup.out
    else {

    Code:
    cat somefile
    Code:
    tail somefile

  9. #9
    Join Date
    Feb 2002
    Posts
    3,729
    This seems to work.

    Thank you very much folks, I appreciate the assistance. =)
    Have you Floble'd today?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •