[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Aus einem Script einen unabhängigen Proze ss starten



Mahlzeit Scheffin, :-)


On Wed, 23 Mar 2005, Michelle Konzack wrote:

> Dachte ich auch, funktioniert aber nicht, denn wenn das Script beendet
> wird und die Funktion noch am laufen ist, wird diese mit beendet...

Kann es sein, daß das Script aus "cron" oder von "ssh $host $scriptname" 
oder von sonst irgendeiner Instanz aus aufgerufen wird, die gleich nach 
dem Ende des Scripts einen logout durchführt?

== cut ==
#!/bin/sh

Machwatt() {
        echo "Gschdadded $1"
        sleep 20;
        echo "Ferdig $1"
}


i=1
while [ $i -le 10 ] ; do
        echo "Starte Machwatt($i)"
        Machwatt $i &
        sleep 2
        i=$(( $i + 1 ))
done

( sleep 5 ; ps axuf | grep $0 | grep -v "grep" ) &

echo "Hauptteil hat fertig"
== cut ==

Wenn Du den Hangup ignorieren willst:

t_antepoth@sofa:~> nohup ./blah.sh 
nohup: hänge Ausgabe an ,,nohup.out" an

und wie man sieht läuft das Script noch:

t_antepoth@sofa:~> tail -f nohup.out 
Starte Machwatt(1)
Gschdadded 1
Starte Machwatt(2)
Gschdadded 2
Starte Machwatt(3)
Gschdadded 3
Starte Machwatt(4)
Gschdadded 4
Starte Machwatt(5)
Gschdadded 5
Starte Machwatt(6)
Gschdadded 6
Starte Machwatt(7)
Gschdadded 7
Starte Machwatt(8)
Gschdadded 8
Starte Machwatt(9)
Gschdadded 9
Starte Machwatt(10)
Gschdadded 10
Ferdig 1
Hauptteil hat fertig
Ferdig 2
Ferdig 3
500       5663  0.0  0.1  2908 1244 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
500       5666  0.0  0.1  2908 1244 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
500       5669  0.0  0.1  2908 1244 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
500       5673  0.0  0.1  2908 1244 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
500       5676  0.0  0.1  2908 1244 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
500       5680  0.0  0.1  2908 1244 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
500       5683  0.0  0.1  2908 1248 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
500       5686  0.0  0.1  2908 1244 pts/3    S    20:22   0:00 /bin/sh ./blah.sh
Ferdig 4
Ferdig 5
Ferdig 6
Ferdig 7
Ferdig 8
Ferdig 9
Ferdig 10



	t++

Reply to: