2016-04-28 3 views

Antwort

0

Das Ausführen mehrerer Befehle, die durch Semikolons getrennt sind, erfordert eine Shell. Um eine solche Shell Funktionen zu erhalten, müssen Sie eine Shell wie in diesem Fall, bash aufrufen:

sudo -u user bash -c 'command1; command2; command3; command4; command5' > out.log 2&1 

Hier sudo -u user bash verläuft bash unter user. Die Option -c teilt bash mit, welche Befehle ausgeführt werden sollen.

0
sudo -u user command1 > outFile; command2 >> outFile; command3 >> outFile; command3 >> outFile; command4 >> outFile; 

Wenn Sie nicht wollen nachfolgenden Befehl auszuführen, wenn die vorherigen dann gescheitert ...

command1 > outFile && command2 >> outFile && command3 >> outFile && command3 >> outFile && command4 >> outFile; 

Beachten Sie, dass Ausgang COMMAND1 wird das outFile geleitet von ' > '(wodurch eine Datei erstellt und die Ausgabe hinzugefügt wird), während alle nachfolgenden Befehle über' >> '(die die Ausgabe anhängen) weitergeleitet werden

Verwandte Themen