Run script in background

hello,
I connect with server via ssh.When I execute some script there and quits session script execution also quits,(1)I want to know that how can I execute a script so that if I logoff its execution may not effect.
(2) if we can execute script in background how can we check its status and is it possible to bring it foreground?
regards,
tanveer

thbaig wrote:
hello,
I connect with server via ssh.When I execute some script there and quits session script execution also quits,(1)I want to know that how can I execute a script so that if I logoff its execution may not effect.man nohup
You might also want to look into Gnu's screen program.
alan

Similar Messages

  • Run script to background wo/ showing the pid and done status [SOLVED]

    I have a little script I wrote that I execute in my ~/.zshrc that I would like to run in the background without printing out the pid of the background process and the done status.  Is this possible?
    Example:
    << ~/.zshrc is sourced and it runs this line>>
    << ~/bin/check& >>
    [1] 13047
    grtaysky@host ~ %
    [1] + 13047 done ~/bin/check
    What I want to see is:
    << ~/.zshrc is sourced and it runs this line>>
    << ~/bin/check& >>
    grtaysky@host ~ %
    Last edited by graysky (2014-07-20 10:32:02)

    Trilby wrote:
    ( your command & ) >/dev/null 2>&1
    I've just revised my "hush" function from the former to the latter here to get just this same result.  I've been testing it and it works well (in bash):
    #hush() {
    # setsid $@ >/dev/null 2>&1 &
    hush() {
    (setsid $@ >/dev/null 2>&1 &) >/dev/null 2>&1
    Hmm... why do you background it? Isn't `setsid "$@" > /dev/null 2>&1` enough?

  • Running script in background

    I'm trying to run a script for moving and compressing files in the background. I'm concluding that there is no way to do this directly in an AE ExtendScript? Perhaps in Bridge? Perhaps as a plugin developed using the SDK? Thanks

    It seems to be failing on everything.  For instance, I type:
    find / -name *.doc &
    That's a command that I know is going to take a while.  On OS X, the process says in the foreground.  If I go to my Linux Machine (Oracle Enterprise Linux aka CentOS 6.5 aka RedHat Enterprise), and issue the exact same command, it pushes the task into the background - no issues whatsoever.
    You are correct, the command line option is "startvm".  My script's name is "startvms" (startvms.sh to be exact).  I have typed it so many times that I just naturally add the "s" on the end.    In that case, if I would used the option "startvms", it would have errored out:
    # VBoxHeadless -startvms d3945f66-6abd-4f0c-8cb4-ef0fd67c4de4
    Oracle VM VirtualBox Headless Interface 4.3.20
    (C) 2008-2014 Oracle Corporation
    All rights reserved.
    VBoxHeadless: error: Invalid parameter: d3945f66-6abd-4f0c-8cb4-ef0fd67c4de4
    Thanks for the eagle eye..it's always good to have a really detailed person look things over!
    I don't know if you ever have the need for running VMs for any reason, but I have found that VirtualBox simply outdoes Parallels and VMWare, especially for portability and price.  No mater the host (Windows, OS X, Linux, Solaris) it functions everywhere.  I can literally develop web server and database on a Mac, demo it on a Windows box, then deploy it on a Solaris server.
    One time I literally saved a crashed Windows 2008 server (hardware) by converting the actual disk image to a VDI, created a VM and imported it and ran it on an old XServe with VirtualBox.

  • 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.

  • Running sh script in background

    I am implementing a indoor location system using cricket motes. Placing these motes around the room allows for tracking.
    My problem is:
    I am running an sh script file in the background, but I don't think I understand the full concept of running script files in the background.
    When I enter the command, ./launchall.sh, my script file, launchall.sh, launches 3 java applications.
    As a result, the cygwin shell (terminal window) shows text output and two of the launched applications displays windows (BeaconFinder application is a graphical display to show locations of beacon motes and BeaconConfiguration application displays a window to show beacon location measurements).
    When I enter the command to run the same script file in the background, ./launchall.sh &, the same thing happens. I do not see any difference between running this application in the foreground or background.
    Can anyone explain the difference of running script files in the foreground and background.
    My problem is, I need to run a second script file in another directory while the first script is running in the background.
    I was under the assumption, that when the ampersand (&) is used, the terminal window gives the prompt back right away so you can enter more commands (and I need to enter another command).
    My second script file launches a java application, but the first script file must be running because it allows me to configure my beacon motes. However, I am not able to enter my second command, ./launch.sh, because the terminal window is being filled with output location measurements from the first script file.
    I hope I have explained my problem thoroughly.
    The commands I entered:
    cd /opt/cricket2.0/demo
    ./launchall.sh &
    I need a prompt so I can also run my second script while first
    script is running in the background:
    cd /opt/cricket2.0/src/app/clientlibexample
    ./launch.sh
    Thanks

    This has all been explained in your [url http://forum.java.sun.com/thread.jspa?threadID=701419&messageID=4068792#4068792]other post.
    You got the meaning of background vs. foreground correctly, the latter does not return to the prompt as long as the process is running.
    As for the output you see, that's the reason we told you means by which you could suppress it (the "2>&1 > output.log" or "2>&1 > /dev/null" part).
    The sole point you're mistaken at is that you actually can run your second script even with the other one polluting the console. You just don't see anything really, but if you type in your command and hit enter, it'll work.
    To summarize:
    Be [name_out] the name of a file you want your standard output (System.out) to be written to,
    Be [name_err] the name of a file you want your error stream (System.err) to be written to,
    Be [scriptname] the name of your script,
    then type in, in the appropriate working directory:
    ./[scriptname] 1>>[name_out] 2>>[name_err] &

  • Running thread in background.

    I am running a program from within a terminal and when a certain action is performed I want a new thread to start running in the background. However when I do thread.run() it still runs in the terminal. I know if you want to run a program in the background you can do program&, but what would be the similar method call?
    Thanks.

    Currently when the thread is run it holds up the
    terminal. I want to make it so I can still use the
    terminal once the thread has been started, hence
    running it in the background.I think you're confusing the issue by talking about threads here. You actually seem to be asking how to detach the process from the terminal. I'm afraid Java doesn't support this operation.
    If you want this behaviour you will have to achieve it via operating system features. If you want the process to transition from an attached to a detached mode during its execution, you will probably have to make use of JNI to achieve this. If you want it to start out (and stay) detached, you will be able to use a shell script (or on Windows the javaw command).

  • Running InDesign in background

    So I wrote an automerge script for InDesign CS5.5 with ExtendScript and javascript. It works fine opening the document and merging records then save and close... Is there a way to have this run in the background instead as like a background task?

    I usually do it like this:
    main ();
    function main () {
        try {
            if ( parseInt ( app.version ) > 6 ) {
                var
                    _scriptRedraw = app.scriptPreferences.enableRedraw,
                    _userInteraction = app.scriptPreferences.userInteractionLevel;
                app.scriptPreferences.enableRedraw = false;
                app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
                if ( app.documents.length ) {
                    var
                        _dP = app.documents[0].preflightOptions.preflightOff;
                    app.documents[0].preflightOptions.preflightOff = true;
                    app.doScript ( doStuff, undefined, undefined, UndoModes.ENTIRE_SCRIPT, "My Function" );
                    app.activeDocument.preflightOptions.preflightOff = _dP;
                } else {
                    /* NO DOCUMENTS OPENED */
            } else {
                /* WRONG APP VERSION */
        } catch ( _ ) {
            /* DISPLAY SCRIPT ERRORS */
        } finally {
            app.scriptPreferences.enableRedraw = _scriptRedraw;
            app.scriptPreferences.userInteractionLevel = _userInteraction;
    function doStuff () {
        /*DO YOUR STUFF*/
    Hope that helps.
    Marijan (tomaxxi)
    http://tomaxxi.com

  • Can Photoshop CS3/4 be run as a background application ?

    We use Enfocus Powerswitch to automate pre-press/pre-media workflows for our Photographic studios. The main application called is of course PSH and it always brings itself to the front window even though it's not necessary and wastes time doing it to then perform what ever actions / scripts needed on the pic files.
    Is there any way to tell PSH not to come to the front and run in the "Background" ?

    I think if one employs BridgeTalk in JavaScript for Illustrator for example Photoshop need not be brought to front to perform its tasks.
    But isn’t that behaviour in this case dependent on the program You use (Enfocus)?

  • Running script automatically at startup at system level

    Hi all,
    I am a newbie with MAC. I am looking for some application that is equivalent to Window's Task Scheduler - bascially, I have a bash script and I would like it to start running at startup and be always running in the background, no matter who logs into the computer, and whoever logged in can restrat the script if needed.
    Background info (if that helps understand what I am trying ot accomplish):
    I am using Selenium (a UI automation tool) to automate some web testing, and my script will be calling the Selenium library to start a server to listen for requests, and it will launch browser and run tests when a request comes in.
    Long story short about what I want:
    I would like to automate opening up a terminal and running a bash script when my MAC starts up, and have the script always running in the background regardless of which user is currently logged in, and I would like the user to be able to stop the script and restart it if it somehow gets stuck.
    I did some quick research and found out about Automator. I would like to find out/confirm if Automator is what and all I need? If not, what are my options out there?
    Any suggestion and advice would be greatly appreciated! Thank you so much for reading!

    I'm not sure whether this should be a LaunchDaemon or a LaunchAgent - if it requires user interaction as you sugest it should really be the latter, so that's what I'll show how to do.
    Open TextEdit, make sure the open document is set to plain text (not rich text), copy in the following text, then save it as user.bash_script.autostart in the folder /Library/LaunchAgents/.  Then restart the machine or load the plist using launchctl in terminal.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>RunAtLoad</key>
              <true/>
              <key>Label</key>
              <string>user.bash_script.autostart</string>
              <key>Program</key>
              <string>/path/to/bash script</string>
              <key>KeepAlive>
              <true/>
    </dict>
    </plist>
    This job will start the script as a daemon so that it's running for all users.  The KeepAlive key specifies that if the daemon quits launchd should automatically restart it.  It's up to you to make sure users have the correct permissions to quit the process if it gets stuck.
    Note: using a LaunchAgent means that a separate instance of this process will be created for each user who logs in, and that the process will not be running if no user is logged in.  if you need to have one running instance for all users you need to use a LaunchDaemon.  However, LaunchDaemons are not supposed to have user interaction, which it seems like you want.  more details would be helpful.

  • Apple Script Editor | Background Process | Question

    Hi,
    I recently found this chat site called www /dot/ omegle /dot/ com (The service randomly pairs users in one-on-one chat sessions where they chat anonymously using the handles "You" and "Stranger".) - and i was wondering how i could create a copy and paste routine to run in the background on safari while i do other stuff on Google Chrome or whatever.
    Here is an example of my script so far:
    repeat 10000 times
      delay 4
              tell application "System Events" to keystroke "v" using command down
              delay 0.1
              tell application "System Events" to keystroke return
      delay 1
              tell application "System Events" to keystroke (key code 53)
              delay 0.5
              tell application "System Events" to keystroke (key code 53)
              delay 0.5
              tell application "AppleScript Editor" to activate
              tell application "System Events"
      key down {command}
      keystroke (key code 14)
      key up {command}
              end tell
              tell application "System Events"
      keystroke "r" using {command down}
                        tell application "System Events"
      keystroke "r" using {command down}
                                  tell application "Safari" to activate
                        end tell
      delay 3
                        tell application "System Events" to keystroke (key code 53)
      delay 4
                        tell application "System Events" to keystroke "v" using command down
                        delay 0.1
                        tell application "System Events" to keystroke return
      delay 1
                        tell application "System Events" to keystroke (key code 53)
                        delay 0.5
                        tell application "System Events" to keystroke (key code 53)
                        delay 0.5
                        tell application "AppleScript Editor" to activate
                        tell application "System Events"
      key down {command}
      keystroke (key code 14)
      key up {command}
                        end tell
                        tell application "System Events"
      keystroke "r" using {command down}
                                  tell application "System Events"
      keystroke "r" using {command down}
                                            tell application "Safari" to activate
                                  end tell
                                  delay 3
                                  tell application "System Events" to keystroke (key code 53)
                        end tell
                        delay 0.1
                        tell application "System Events" to keystroke (key code 53)
              end tell
    end repeat

    Anyone?
    I'm not trying to spam anybody - i just wan't to promote my band.

  • Running Export on Background

    I have the following script for export and details are as follows,
    nohup export_aaa Export command:
    oracle@eccprod:/big_files/mjk> cat export_aaa
    gzip < exp_pipe > exp_ccprod_aaa.dmp.gzip &
    exp parfile=exp_ccprod_aaa.par
    exp_ccprod_aaa.par:
    oracle@eccprod:/big_files/mjk> cat exp_ccprod_aaa.par
    userid="/ as sysdba"
    owner=('AAA')
    consistent=y
    direct=y
    compress=n
    statistics=none
    file=exp_pipe
    log=exp_ccprod_aaa.log
    feedback=100000
    buffer=2000000
    I am not sure the whether the export_aaa script is correct or not. moreever i need to run this script in background. can you please correct me if anthing wrong on this export_aaa and help me ro run this script in background.

    Hai ,
    Try tihs out
    ORACLE_BASE=new/oracle          export ORACLE_BASE
    ORACLE_HOME=$ORACLE_BASE/product/102   export ORACLE_HOME
    ORACLE_SID=SENC1
    PATH=/usr/ccs/bin:$PATH:$ORACLE_HOME/bin
    export PATH
    DT=`date +"%Y%m%d%H%M%S"`
    rm -f /tmp/exp_pipe_full_senc1
    /usr/sbin/mknod /tmp/exp_pipe_full_senc1 p
    nohup compress < /tmp/exp_pipe_full_senc1 > /backup/database/exp_SENC1_"$DT".dmp.Z &
    nohup $ORACLE_HOME/bin/exp username/password@senc1 file=/tmp/exp_pipe_full_senc1 log=/backup/database/exp_SENC1_"$DT".log grants=none statistics=none &It exports and compresses immediately.works fine in our environment
    Thanks
    Kai

  • Running job in background

    Hi,
    I am using oracle 10.2.0.4 and HP UX .
    I want to run job in background .For this i created on sql file "stat.sql"
    execute sys.dbms_stats.gather_schema_stats( ownname=>'PRD',cascade=>FALSE,degree=>dbms_stats.default_de
    gree, estimate_percent=>100);
    and then i created one "statscr.sh" file to run this script.
    #!/bin/ksh
    sqlplus sys/sys as sysdba
    @/home/oracle10/stat.sql
    exit
    i am running this by
    nohup ./statscr.sh >/home/oracle10/stat.log &
    But soon it displaying message ...
    /home/oracle10 > nohup ./statscr.sh >/home/oracle10/stat.log &
    [1] 27188
    [1] + Done(126) nohup ./statscr.sh >/home/oracle10/stat.log &
    How to check this job is running in backuground or not .. in ps -ef|grep nohup it is not displaying anything .
    OR is there any thing wrong in my steps ...
    Thanks

    Hi,
    i missed to reply your part ..
    See when i loged in to system .. it is prompted me like
    oracle10@n2v4d1/PRD
    /home/oracle10 >
    i tried by "jobs" but it not showing anyting ...
    this is one time activity till now ..i need to run few sql script before starting this job and after finishing this job ...
    those scripts are taking less time . so i am doing directly in sql prompt ..
    I don't know when previous script will fininsh ,so i am not able to tell time when i can run this script.
    can you find any mistake in my shell script or sql script or executing command nohup ...
    Thanks

  • Need User input pop-up in powershell when its run as a background process of an Application

    Hi,
    I have created a powershell script which requires two parameters to be passed onto it for getting executed. This script is called by an application and runs it in background (no console /  window). During this process the application is unable to complete
    the execution of the script due to the missing user inputs (no popup comes for entering parameters by even after using read-host/[system.console]::Read()). 
    The powershell.exe process can only be seen in task manager.
    Is there a way in which my script will create a pop up and ask for the parameter values?
    Thanks,
    Sushruta Banerjee

    Hi,
    I have created a powershell script which requires two parameters to be passed onto it for getting executed. This script is called by an application and runs it in background (no console /  window). During this process the application is unable to complete
    the execution of the script due to the missing user inputs (no popup comes for entering parameters by even after using read-host/[system.console]::Read()). 
    The powershell.exe process can only be seen in task manager.
    Is there a way in which my script will create a pop up and ask for the parameter values?
    Thanks,
    Sushruta Banerjee
    Note that a process that runs with hidden windows will have all of its child process windows hidden. Any popup you add to the script will behidden.  There is nothing you can do about that.  This is by design.
    ¯\_(ツ)_/¯

  • Run VLC as background through Applescript, and more

    Qualifiers:
    VLC version 0.9.10
    OSX 10.4.11
    Applescript 2.1
    I am trying to set up an Applescript to run VLC in stream capture mode in the background.   I can get it to work with:
    do shell script "[path to bundle in VLC app] [stream URL] --sout=file/raw:[path to saved file].raw &> /dev/null 2>&1& echo $!"
    This opens up a VLC application window, captures, and all is fine.  Before I routed all the output at the end of the command it would capture the stream but the script would remain frozen until I quit the VLC application, hence the stuff at the end.  My script needs to keep running actively because it includes a component to periodically check the capture is still taking place (my Internet connection can be dodgy with wi-fi interference from neighbors) by monitoring the modification date of the capture file, so I have to route the output to null so the script doesn't hang.  I tried running it with just the background & and it still hung.  Oh, I am capturing the PID so I can include a kill command to stop the process later.
    I tried doing something similar with
    do script with command etc. -- (modification of end of command line so it finishes after ".raw")
    in Terminal and it worked too, though it opened up a couple of Terminal windows which had to stay open all the time and when I wanted to stop the capture I had to close the VLC Terminal window.
    Now the real issue.  I want to have a second copy of VLC running for other use while the first is doing things quietly.  I know it can be done.  Before writing my Applescript I used to have one copy of VLC in GUI mode capturing a stream and a second copy of the app in GUI for playing other media, both running happily side by side.  It also worked when I ran it from an Applescript with the first VLC channeling through Terminal output. Now when I have the first copy running via Applescript I can open the second copy but when I try to play a file VLC just plays the whole thing back in a few seconds with no output.  It seems the output channeling from the first command line invocation of VLC is also influencing the second application (?? !)  Although I have renamed the application I didn't start messing with things in the app package itself so maybe I also need to change some identifiers in plist settings or bundle names so it really is accepted as a completely different app?
    I know this is a mix of archaic OSX technologies, both Unix and Applescript, and maybe something non-Apple and VLC-specific but I spent an hour or two doing web searches for tips, and a lot of experimentation with various combinations myself and didn't get far.  I am not sure if I have explored all the possibilities with the shell command, or if I can do something to change my second VLC application so it truly stands alone, or this just won't work, or...?
    Oh, just in case somebody suggests it, using an "open" in a shell script does not have a -n flag under Tiger OS, so I can't start a new instance of the old VLC that way (and it may suffer the same problem).

    I discovered that even when I quit my script and tried running VLC normally after that it still wasn't playing things normally although repeated runs of the script go things running in the background fine.  I trashed VLC's preferences and things played normally.  I really wish I know how to get a second copy of VLC to run in complete isolation of the first, including separate preferences, since it is a nuisance to have to trash preferences to switch between uses of VLC.

  • How do I find out what applications are running in the background

    I have a 2008 iMac with 2GB memory.  How do I find out what programs are running in the background?  I am going to buy a new iMac before the end of the year to replace this one.  When I looked at Activity Monitor it shows 1.8Gb used but doesn't tell all the programs running.

    open activity monitor [if it doesnt launch click winders>Activity Monitor]. then it'll show all proceses

Maybe you are looking for

  • Projectwise settlement report for a given period

    Dear PS experts, Is there any report which i can see the projectwise settlement to AUC, Fixed asset and Cost center for a given period?. Regards Vetrivelan.

  • Is there a plugin to view .sgi file formats in preview on OSX 10.6?

    As the subject line indicates, is there a plugin (free or non-free) that will allow me to preview .sgi file formats in Preview on OSX 10.6. The functionality previously existed  by default but with Snow Leopard, it appears it was removed. Thanks for

  • Netegrity - Portal 7 integration

    I have a requirement where the WLP 7 is behind a Netergrity SSO enabled IPlanet WebServer. Need to automatically log the users in to WLP 7. BEA Portal support mentioned CCE has developed a beta BEA supported integration between WLP 7.0 and Siteminder

  • Connection Manager in 11.1.2

    Hi , I am new to smart view version 11.1.2. I have to add new URL in connection manager. Can somebody help me to do this. I opened shared connections, and searching for action panel to add the URL for HFM. I don't see anything to add the url. "Do i n

  • Connection jdeveloper with database

    I make the following: right click on database, new connection, I put the connection name (connaction type is "oracle (jdbc)"), username hr, password hr, deploy password is selected and now if I let the default option :driver - thin, hostname -localho