如何在backgound中仅运行第一个命令?
我想只发送第一个命令在后台运行。 我怎样才能做到这一点?
例如,对于此命令
sudo apt-get update & && apt-get upgrade
我的第一个命令必须在第二个命令之前运行,如上所述,我不想先运行第二个命令。 然后上面的例子是非常好的例子,因为我必须在升级之前运行update命令。
但它给出了错误(对于我的真实命令):
bash: syntax error near unexpected token `&&'
两者都在后台:
~$ (sleep 1 &) && (sleep 2 &) ~$
第一个在背景中
~$ (sleep 1 &) && (sleep 2) ~$
不会使用apt-get。
编辑:找到它。
sudo bash -c 'apt-get update >/dev/null 2>&1 & disown' && sudo apt-get upgrade
certificate:
sudo bash -c 'apt-get update >/dev/null 2>&1 & disown' && sudo apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... The following packages were automatically installed and are no longer required: gtk2-engines-pixbuf libcrypt-blowfish-perl libcrypt-cbc-perl libcrypt-rijndael-perl libexpect-perl libgnome2-gconf-perl libgtk2-ex-simple-list-perl libgtk2-gladexml-perl libgtk2-unique-perl libio-stty-perl libkeybinder0 libnet-arp-perl libnet-pcap-perl libnet-proxy-perl libossp-uuid-perl libossp-uuid16 libunique-1.0-0 libxml-parser-perl python-keybinder Use 'apt-get autoremove' to remove them. Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
并且更新仍在运行:
~$ ps -ef|grep apt-get root 6102 1519 1 12:11 pts/0 00:00:00 apt-get update
它会破坏序列:升级将在更新之前完成。