DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: How to run my script as a background job in UNIX?

  1. #1
    Join Date
    May 2001
    Posts
    285

    Question How to run my script as a background job in UNIX?

    I have a script which does nothing but analyze all tables, while another one is to analyze all indexes. On one side, this is a one time process for testing, so I am not going to do this as a cronjob. And on the other side, it could be hours before this script finishes running, so I'd like to run it in the background.

    I know it's doable on UNIX, but how can I achieve that? An example will be specially appreciated...

    FYI - it's a SUN box. Let me know if you need other info...

    Elaine

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    have a script with in it for example

    #!/bin/ksh
    sqlplus user/pass@instance < analyze table xxx compute statistics;
    analyze table yyy estimate statistics;
    exit
    EOF

    The from the command line

    nohup ./script.ksh &

    You can then disonnect your session and it will run in the background


    Hmm this forum messes up two of these < was supposed be two of them followed by EOF and then the commands
    Last edited by marist89; 07-02-2004 at 10:25 AM.

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    I use screen sometimes, been using since University days. Quite useful to run jobs (not background, I run them in foreground then detach the screen). By default you can open up to 10 terminals in same telnet/ssh session then to leave the job running and not get hang up just detach the screen.

    Search unix detach screen in google

Posting Permissions

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


Click Here to Expand Forum to Full Width