別画面で2つのコマンドを実行する

別画面で2つのコマンドを実行する

ファイルをダウンロードしようとしていますが、wgetバックグラウンドとは別の画面にあります。

私の初期コマンドは次のとおりです。

wget http://www.example.com/file.zip -O temp/file.zip; mv temp/file.zip downloads/file.zip;

downloads/これにより、ダウンロード後にファイルがスムーズに移動され、ファイルがバックグラウンドでダウンロードされている間にファイルを処理できなくなります。

これで、画面があるバックグラウンドで実行する必要があるため、実行して分離します。

screen -dm wget http://www.example.com/file.zip -O temp/file.zip;

しかし、どのように移動コマンドを渡し、最初のコマンドが完了したら実行することができますか?

編集する:DopeGhotiの答えに基づいて引用を試しました。

 screen -dm 'wget http://mirror.leaseweb.com/speedtest/100mb.bin -O 1.bin; mv 1.bin 2.bin'
 cannot identify account 'wget http:'.

これ:

 screen 'wget http://mirror.leaseweb.com/speedtest/100mb.bin -O 1.bin; mv 1.bin 2.bin'
 cannot exec 'wget http://mirror[...] no such file or directory

編集する:/usr/bin/wgetフルパスとパスを試してみましたが、セッション名が欠落していると文句を言い/usr/bin/mvました。セッション名を指定しましたが、-S foo次のように再開する画面もなく、ダウンロードしたファイルもなく自動的に終了します。

screen -dm -S foo '/usr/bin/wget http://mirror.leaseweb.com/speedtest/100mb.bin -O 1.bin; /usr/bin/mv 1.bin 2.bin'

ベストアンサー1

私が指定した場合は動作しますバッシュ-c

screen -dm bash -c 'command1; command2;'

ユーザーまあこのソリューションはコメントで提供されました。ありがとうございます。

おすすめ記事