From: Thomas Schweikle <tps@vr-web.de>
To: gentoo-user-de@lists.gentoo.org
Subject: [gentoo-user-de] Re: Bash-Skript Frage
Date: Sat, 20 Aug 2005 15:16:13 +0200 [thread overview]
Message-ID: <1124543773.583312@hazel> (raw)
In-Reply-To: <43070874.7080507@gmx.net>
Hendrik Jürgens schrieb:
> Thomas Schweikle wrote:
>>> Nils Andresen schrieb:
>>>
>>>>Moin,
>>>>
>>>>Volker Katz wrote:
>>>>
>>>>
>>>>>Also in der Art:
>>>>>
>>>>>/bin/job1 &
>>>>>/bin/job2 &
>>>>>/bin/job3 &
>>>>>while (not job1 finished && not job2 finished && not job3 finished)
>>>>>/bin/job4
>>>>>
>>>>>
>>>>
>>>>Macht
>>>>( /bin/job1 & /bin/job2 & /bin/job3 ) && /bin/job4
>>>>nicht das ?!
>>>
>>>
>>> Nein, macht es nicht:
>>> - job 1 wird im Background ausgeführt
>>> - job 2 wird im Background ausgeführt
>>> - job 3 wird im Vordergrund ausgeführt
>>> nach *erfolgreichem* beenden von job 3 wird job 4 ausgeführt.
>>>
>>> Die Klammern um job 1 bis job 3 sorgen nur dafür, dass das Environment
>>> (bis auf den Rückgabewert) nicht verändert wird.
>>>
>>> (sleep 60 & sleep 60 & sleep 5) && echo "Fertig!"
>>> ps axf nach 0s:
>>> 13619 pts/1 Ss 0:00 \_ -/bin/bash
>>> 2846 pts/1 S+ 0:00 | \_ -/bin/bash
>>> 2847 pts/1 S+ 0:00 | \_ sleep 60
>>> 2848 pts/1 S+ 0:00 | \_ sleep 60
>>> 2849 pts/1 S+ 0:00 | \_ sleep 15
>>>
>>> ps axf nach 10s:
>>> 2847 pts/1 S 0:00 sleep 60
>>> 2848 pts/1 S 0:00 sleep 60
>>>
>>> ps axf nach 61s:
>>>
>
> Tach.
>
> Damit sollte das vielleicht so gehen. Die jobs 1-3 werden im Hintergrund
> ausgeführt. Ihre PIDs in den Variablen job1-3 gespeichert und danach auf
> das Beenden der Jobs gewartet, bevor job4 ausgeführt wird,
>
> #!/bin/bash
> job1 & job1=$!
> job2 & job2=$!
> job3 & job3=$!
> wait $job1
> wait $job2
> wait $job3
> job4
>
> wait $wmpid
Ja. nur gefällt mir die Variante aus
<20050816151216.GA32458@stovokor.kiste.lan> besser. Ich würde hergehen
in das ganze in eine Schleife packen:
for i in job1 job2 job3 jobn; do
$i & pids="${pids} $!"
done
wait $pids
echo "Fertig!"
noch eleganter:
function waitjob() {
$* & pids="$pids $!"
}
waitjob job1
waitjob job2
waitjob jobn
wait $pids
echo "Fertig!"
--
Thomas
--
gentoo-user-de@gentoo.org mailing list
prev parent reply other threads:[~2005-08-20 13:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-16 14:16 [gentoo-user-de] Bash-Skript Frage Volker Katz
2005-08-16 15:12 ` Emil Beinroth
2005-08-16 17:14 ` Nils Andresen
2005-08-20 5:01 ` Karsten Schulz
2005-08-20 10:04 ` [gentoo-user-de] " Thomas Schweikle
2005-08-20 10:39 ` Hendrik Jürgens
2005-08-20 13:16 ` Thomas Schweikle [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1124543773.583312@hazel \
--to=tps@vr-web.de \
--cc=gentoo-user-de@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox