Find out the process id from a background running script

Hello all:
I created a java service and use a shell script to drive it from background. In the script, I have code like this:
javac myApp & I want to find out the pid for this process. After googling for a while I came up with this:
echo $$ > test.pid However, I notice two things:
1. This only works when my script runs frontground, meaning only when I remove "&";
2. The pid file, test.pid, won't be created until the running script exits, after I clicked ctrl+c, for instance.
Now the question is, how can I find out the pid of a background running script from within the script itself?
I don't want to use code such as ps -ef | grep .... because of the possible name conflict.
Thanks,
Johnny

Yes, but as far as I understand this can happen to any background process, for instance, when the user logs out while a background process is still running.
But using the "$!" variable as you've shown is the "correct" solution.
This is probably what the OP is looking for:
javac myApp & echo $! > test.pidFrom the bash man page:
$ Expands to the process ID of the shell. In a () subshell, it expands to the process ID of the current shell, not the subshell.
! Expands to the process ID of the most recently executed background (asynchronous) command.

Similar Messages

  • Find out the peak position from graph

    Hello All,,
    Actually i want to run this algorithm real time,, to find out the peak position from graph ,, i need to generate the position automatically,,, firstly i try to use image processing by  apply threshold followed by edge detection and the find out the center of each  detected part. the drawpack of this procedure is that the obtained images are different and that lead to different threshold values,, so how can i directly find the position from the graph,,, here i attach the image and the graph of the image,,
    thank you,,
    Attachments:
    11.png ‏15 KB
    13.PNG ‏85 KB

    Hello Klemen: 
    here i will explain in more details: the main objective of my work is to calculate velocity of small particle,, i perform my experiments by exposing the particle to 2 light pulses,, and i know the time between the two pulses,, so i need to know the distance to calculate the velocity,,, for that i apply correlation,,, the spot that appear in the correlation image is an indication of symmetry,,,so i should know the location of maximum intensity of each peak. The central peak (highest intensity) will be the reference (zero point) and the other peaks locations should be subtracted from the reference peak to determine the shift,,,
    Here is the sequence of the process:
    Acquiring raw image, correlation, position of central peak, shift calculation, velocity determination,,,,,
    applying image processing is good idea in case of post processing condition,,, but in my case i need it real time, that mean if i need to apply image processing for calculation, i have to find out a universal criteria for threshold value that can be applied for all raw images,, from my experiments i didn't find specific criteria & i have to manually change the threshold value,,
    If I choose the intensity (grey level) to be the criteria, then the small peaks (symmetry) will not take place,, because their intensity is very low compare to the central peak,,,
    So the most reliable procedure is to directly find out the position of the two small peaks beside the central peak and save this values into an array and use it for calculation,,, I hope I am clearly explain my problem..
    Thanks 
    Attachments:
    7-2.png ‏36 KB
    7-1.png ‏3 KB
    7-700.PNG ‏123 KB

  • How can I find out the mail server from email address?

    Hi:
    How can I find out the mail server from email address?
    for example: If I know the email address is [email protected],
    how to find the pop3 and smtp mail server?
    THANK YOU

    You can't tell by the email address since you can pretty much put whatever you want in there (especially if the SMTP server is not filtering anything).
    The header may be able to tell you something. There is a Received header value which looks like it has the routing information although I am not sure if this is a complete trace or just the last hop the message took.
    Sean

  • HOw to find out the RFC destination from BW system to ISU

    Hi,
    Currently my requirement is to call a function module which is written in ISU (remote enabled) from BW system.
    I am unable to find out the rfc destination from BW to ISU system.
    In CRM we have table like smofparsfa1. Is there any table in BW which can provide me the ISU destination?
    I need to compare the records stored in isu as well as in BW system.
    I need to call a function module which will provide me the data from isu.
    please help me in this regard.
    Krishna

    Hi,
    You can check it in SM59 if there are any RFC destinations for the above systems.
    Alternatively ,check the table RFCDEST if any entries are maintained
    Regards,
    Lakshman.

  • How to find out the process chain

    Hi folks
    Hope every one is doing good..!
    in sm37 my job is running (ABAP program) which is in process chain, but i have to find out the process chain name..!
    Could any one help me on this..!

    hi,
      in SM37 select the job status as active and execute it, in the next screen you  will find only active jobs select your job (ABAP Program) click on step - > in th next screen put the cursor on the job -> select Goto option in menu bar click on variant it gives you the field names and desc like chain name, variant etc information.
    Regards
    Sankar

  • How find out the duplicate value from each columns.

    I have below four columns,
    How can i find out the duplicate value from each columns.
    with All_files as (
    select '1000' as INVOICE,'2000' AS DELIVERYNOTE,'3000' CANDELINVOICE,'4000' CANDELIVERYNOTE from dual union all
    select '5000','6000','7000','8000' from dual union all
    select '9000','1000','1100','1200' from dual union all
    select '1200','3400','6700','8790' from dual union all
    select '1000','2000','3000','9000' from dual union all
    select '1230','2340','3450','4560' from dual
    SELECT * FROM All_files
    Output should be as per below.
    1000 2000 3000 4000
    9000 1000 1100 1200
    1200 3400 6700 8790
    1000 2000 3000 9000
    Required to check uniqueness in cross columns.
    Thanks.

    Try this (sorry about the formatting)...
    WITH all_files AS (SELECT   '1000' AS INVOICE,
                                '2000' AS DELIVERYNOTE,
                                '3000' CANDELINVOICE,
                                '4000' CANDELIVERYNOTE
                         FROM   DUAL
                       UNION ALL
                       SELECT   '5000',
                                '6000',
                                '7000',
                                '8000'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '9000',
                                '1000',
                                '1100',
                                '1200'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1200',
                                '3400',
                                '6700',
                                '8790'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1000',
                                '2000',
                                '3000',
                                '9000'
                         FROM   DUAL
                       UNION ALL
                       SELECT   '1230',
                                '2340',
                                '3450',
                                '4560'
                         FROM   DUAL),
        t_base
           AS (SELECT      invoice
                        || ','
                        || deliverynote
                        || ','
                        || candelinvoice
                        || ','
                        || candeliverynote
                           str
                 FROM   all_files),
        t_str
           AS (SELECT   str || ',' AS str,
                        (LENGTH (str) - LENGTH (REPLACE (str, ','))) + 1
                           AS no_of_elements
                 FROM   t_base),
        t_n_rows
           AS (    SELECT   LEVEL AS i
                     FROM   DUAL
               CONNECT BY   LEVEL <=
                               (    SELECT   SUM (no_of_elements) FROM t_str)),
        t_build AS (SELECT   t_str.str,
                             nt.i AS element_no,
                             INSTR (t_str.str,
                                    DECODE (nt.i, 1, 0, 1),
                                    DECODE (nt.i, 1, 1, nt.i - 1))
                             + 1
                                AS start_pos,
                             INSTR (t_str.str,
                                    1,
                                    DECODE (nt.i, 1, 1, nt.i))
                                AS next_pos
                      FROM      t_str
                             JOIN
                                t_n_rows nt
                             ON nt.i <= t_str.no_of_elements),
        t_build2
           AS (SELECT   RTRIM (str, ',') AS original_string,
                        SUBSTR (str, start_pos, (next_pos - start_pos))
                           AS single_element,
                        element_no
                 FROM   t_build),
        t_build3
           AS (SELECT   single_element,
                        COUNT( * )
                           OVER (PARTITION BY single_element
                                 ORDER BY single_element)
                           ele_count
                 FROM   t_build2)
    SELECT   DISTINCT INVOICE,
                      DELIVERYNOTE,
                      CANDELINVOICE,
                      CANDELIVERYNOTE
      FROM   all_files, t_build3
    WHERE   ele_count > 1
             AND (   INVOICE = single_element
                  OR DELIVERYNOTE = single_element
                  OR CANDELINVOICE = single_element
                  OR CANDELIVERYNOTE = single_element)I think this will be faster than the previous solution?
    Cheers
    Ben
    Edited by: Munky on Feb 17, 2011 2:11 PM - "I think this will be faster than the previous solution?", nope - it's not :(

  • Need to know how to find out the Variant associated with a background job

    Hello,
    Plz help me in finding out how to find the variant associated with a background job. I need to know which variant does the program picks up when it runs the scheduled background job. There are so many variants that exist. How do I figure out which one is being picked up by the program. When I go and see into the job that are already finished it shows the parameter as "&00000000645354" which I do not understand what it corresponds to. I was expecting a variant name instead of this number in the parameter field. Is there a way I can find out the name of teh variant the program is using automatically in the background job ??
    Thanks in anticipation

    Yes it is possible which is variant, input fields are choosen
    - go to SM37 and locate the background job which was processed using proper selection criteria
    - select the Job and click on 'Step' button availabe in the screen
    - the new screen is 'step list overview'. now, place the cursor on selected variant avaialble on the screen, then from Menu >> Goto>> variant
    which gives the list of input values.
    hope this helps
    Thanks
    JK

  • How to find out the batches released from ASCP

    hello gurus,
    Please let me know how to find out the batches which is released from the ASCP in the OLTP OPM instance, like for the Discrete in the WIP Order in the others tabe we can see that there will be a message like " Job mass loadded on......". So is there any way that we can findout whether the batch is released from the ASCP or is it manually created.
    Thanx & Regards

    Hi,
    You can check it in SM59 if there are any RFC destinations for the above systems.
    Alternatively ,check the table RFCDEST if any entries are maintained
    Regards,
    Lakshman.

  • How to find out the process count for a database during a particular window

    Hi Team,
    I want to find out the maximum process count reached for a database for an interval. Say between 1:00 to 2:00 AM IST. Please help
    Database version:11.2.0.2
    OS:AIX 6.1

    Check DBA_HIST_RESOURCE_LIMIT. Your information will be there.
    Simialr information is available in DBA_HIST_SYSSTAT.
    Look for stat name logons cumulative/logons current - Total number of logons since the instance started/Total number of current logons
    You can joing dba_hist_snapshot with snap_id and give begin_interval_time and end_interval_time to know historic process utilization.
    Regards,
    Sreejith

  • Function module to find out the changed values from tables

    What is the standard function module to find out the changed values (the old & new values) from tables in SAP ?

    Hi Harish,
    Please elaborate your requirement...
    Please have a look on CDHDR AND CDPOS tables... it contains changed data... but all chages are not being tracked using it..
    Try Below FMs as well..
    For Header Level...
    CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
        EXPORTING
          date_of_change    = cdhdr-udate
          objectclass       = cdhdr-objectclas
          objectid          = cdhdr-objectid
          time_of_change    = cdhdr-utime
          username          = cdhdr-username
        TABLES
          i_cdhdr           = icdhdr
        EXCEPTIONS
          no_position_found = 1
          OTHERS            = 2.
    For Item Level
    CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
          EXPORTING
            changenumber      = icdhdr-changenr
          IMPORTING
            header            = cdhdr
          TABLES
            editpos           = icdshw
          EXCEPTIONS
            no_position_found = 1
            OTHERS            = 2.
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • How to find out the Menu UID from the main menu

    You can easily Find the Menuuid for menuitem that open a form, but how can you find out the menu uid for f.e. Modules.
    I want to add a submenu under modules.

    Hi Francis,
    You have access to the complete list of menus UIDs into the UI Help File.
    You only have to search for "Menu Items IDs" in the UI Help file.
    Regards,
    Trinidad.

  • Finding out the deleted instance from a recurrent set of events

    Good Morning,
    We have a requirement to find out all the events which belong to a uid in a recurrent event. When the event is created the RRULE returned is:
    RRULE:FREQ=MONTHLY;BYMONTHDAY=16;COUNT=6;INTERVAL=1;WKST=SU
    I then change the date of one of the instance in the event and the rrule and rdate are returned as follows
    RRULE:FREQ=MONTHLY;BYMONTHDAY=16;COUNT=6;INTERVAL=1;WKST=SU
    RDATE:20060717T060000Z
    I then delete one of the instance and there is no change in the properties rrule or the rdate.
    Is there a way to find out the deleted instances in the recurrent set while doing the fetch on the calendar.
    Best Regards
    Joyce

    Good Morning,
    We can use the EXDATE and EXRULE property to get the events in exception.
    Thanks
    Joyce

  • How to find out BPEL process server is up and running?

    Hi All,
    We are invoking a synchronous BPEL process from our application.
    Incase of any network failures, we want to switch to other flow.
    Is there any way to find out the BPEL process server is up and running?
    Thanks,
    Uma.

    Try accessing the dynamic wsdl (http://server.com:7777/orabpel/default/service/1.0/service?wsdl)
    from your application. If there's no error opening this page using http get, the server is alive :)
    Marc

  • Finding out the field name from the columns shown on the screen

    Hi,
    I am new to CRMOD.
    I see a lot of columns shown on the screen, say in the Account object.
    Is there a way to find out which column in the Detail screen maps to which exact field in the Admin page ?
    Appreciate all the help
    Regards

    If you go to Admin > Application Customization > Account > Account Field Setup, you will see the list of all the fields. If you have custom fields, then click on the Rename button on the top left corner of the page, and then Advanced and it will show you the ITAGs of the fields.
    Since you are new to CRMOD, play around with it and also read the help file and you would understand the app a lot better
    Udaya

  • Find out the Extractor names from the Table name

    Hello, I wanted to know given a name of the table in ecc, if there is any way to check which extractors have used this table.
    for example, I have a table name VBAP and I want to see the list of the extractors that are extracting data from this table.
    I tried se11 in ecc, gave the table name and looked the where used list but it doesn't have any options for extractors. I checked all the options with no luck. 

    By using table we won't find data source as you need.
    By experience we can guess the data sources.
    Actually in SAP we 3 category type of applications like
    1. Human resources(HR)
    2. Logistics(LO)
    3. Financial(FI).
    based on application also we have standard data sources as well. Based on table name, you can check the available standard data sources.
    Please check thru in that way.
    You can explore more about  about BW - Extraction part.
    Thanks

Maybe you are looking for

  • K330 with a dead (?) drive

    Saturday, the machine worked fine. Sunday, Win7 updates were done. Tried turning it back on-- "select boot drive". There is NO harddrive option. There is a low, long beep from the drive (not mobo beeps, unplugged HDD-- beeping stopped). Tried to boot

  • TS3276 how do i filter out junk mail on macbook pro

    is there a way to filter the junk mail i recieve

  • CS5 - EPS (vector) opening - How to change/save raster settings?

    Hello to all. I'm working with CS5 now and I mentioned the follwowing terrible fact: When I open a vector EPS in CS5 raster settings are always CMYK and 72dpi. I know very well that CS2 remembers my first type in of settings (e.g. grayscale and 300dp

  • Nokia 311 asha - wifi????

    Nokia, I get mad. My son bought yesterday a Nokia Asha 311. So far everything was ok. But what I do, you can not connect it to the internet via wifi! I updated the phone recently. But it did not help. I have read threads where other owners of that pa

  • VersionMismatch Error when attempting to map a PeopleSoft role in CMC

    ERROR on "Update" to map a PeopleSoft role in CMC "The PeopleSoft Enterprise server returned an error. Error: (SOAP-ENV:VersionMismatch) SOAP version mismatch or invalid SOAP message. Detail: " BOE-XI (R2) BOE PeopleSoft Integration Kit PeopleSoft 8.