UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 28th, 2006, 10:06 AM
KRam1 KRam1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 1 KRam1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 15 sec
Reputation Power: 0
Question How to use background jobs in middle of shellscripts

hi,

i want to write scripts such that the intermediate process that takes 3-4 hours for process should be in background and the fore ground should be carried.

pls give reply ASAP

Reply With Quote
  #2  
Old August 29th, 2006, 04:35 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 759 SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level)SimonJM User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 20 h 48 m 37 sec
Reputation Power: 336
Ok, if I read you correctly what you are after is something like:

Code:
#!/usr/bin/sh
#script.sh
#
# run some short-lived commands
command1
command2
# run a long command and let it run in background
long_command &
# run some more short commands
command3
command4
# now wait for the batch job to end
wait
# and exit script
exit

If you do not care about waiting for the end of the long running job you can omit the wait command.
If you just want to 'fire and forge' the whole thing run via nohup:
Code:
nohup script.sh &

That will let the script survive your terminal session ending.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > How to use background jobs in middle of shellscripts


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT