bash – 在脚本的后台执行shell命令
发布时间:2020-12-15 19:56:18 所属栏目:安全 来源:网络整理
导读:如果命令在字符串中,我如何在bash脚本中的后台执行shell命令? 例如: #!/bin/bashcmd="nohup mycommand";other_cmd="nohup othercommand";"$cmd ";"$othercmd "; 这不行 – 我该怎么办? 留下报价 $cmd $othercmd 例如: nicholas@nick-win7 /tmp$ cat tes
如果命令在字符串中,我如何在bash脚本中的后台执行shell命令?
例如: #!/bin/bash cmd="nohup mycommand"; other_cmd="nohup othercommand"; "$cmd &"; "$othercmd &"; 这不行 – 我该怎么办?
留下报价
$cmd & $othercmd & 例如: nicholas@nick-win7 /tmp $ cat test #!/bin/bash cmd="ls -la" $cmd & nicholas@nick-win7 /tmp $ ./test nicholas@nick-win7 /tmp $ total 6 drwxrwxrwt+ 1 nicholas root 0 2010-09-10 20:44 . drwxr-xr-x+ 1 nicholas root 4096 2010-09-10 14:40 .. -rwxrwxrwx 1 nicholas None 35 2010-09-10 20:44 test -rwxr-xr-x 1 nicholas None 41 2010-09-10 20:43 test~ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |