Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Differences between running in the foreground and the background 1

Status
Not open for further replies.

columb

IS-IT--Management
Feb 5, 2004
1,231
EU
I have a script which looks like
Code:
#!/bin/ksh
 
dt_lin()
 {
 echo $(date +%y%m%d_%H:%M) : $1 >> /home/b40217/testloop.log
 }
 
while [ 1 ]
do
  if ssh testbox "ls /tmp/col050201 >/dev/null 2>&1"
  then
    dt_lin "Found it"
    exit 
  else
    dt_lin "looking"
  fi
  sleep 10
done
If I run this a a foreground process all is well and it duely logs that it is looking every 10 seconds. However I want to run this as a background process so I'm running
Code:
nohup ./testloop &
and after an initial entry there's nothing written to the log or nohup.out. I've checked and ps shows the loop as running. Can anyone explain this please?

Columb Healy
 
What is the behaviour of ssh in background ?
You may try any combination of -f -n and -t options for ssh.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV

Once again you come up trumps!
Many thanks.

Columb Healy
 
Maybe I should have said for others who may read this post the -n option solved it.

Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top