在Linux下,如果你要执行的shell命令耗时特别长,并且:(1)你的网络不稳定,随时可能断网;或者(2)你在执行了shell命令之后必须要关闭终端软件(例如SecureCRT)。 那么你就需要以脱离终端的方式在后台运行这个shell命令。 方法如下: (1)输入命令: nohup 你的shell命令 & (2)回车,使终端回到shell命令行; (3...
使用子 shell 生成一个单独的进程 子shell 是独立的进程。可以使用( )操作符定义子 shell,如下所示: pwd; (cd /bin; ls); pwd; 当在子 shell 中执行某些命令时,当前 shell 中不会发生任何更改;更改仅限于子 shell。例如,在子 shell 中使用cd命令更改当前目录时,目录更改不会反映在主 shell 环境中。
这样的现象被称为在后台(background)运行进程。在后台模式中,进程运行时不会和终端会话上的 STDIN、 STDOUT 以及STDERR 关联。 2.1 后台运行脚本 以后台模式运行shell脚本非常简单。只要在命令后加个& 符就行了。 #!/bin/bash # Test running in the background # count=1 while [ $count -le 10 ] do ...
What happens to background jobs after exiting the shell?In which cases is SIGHUP not sent to a...
bg 将进程搬到后台运行(Background); fg 将进程搬到前台运行(Foreground); 将job转移到后台运行 如果你经常在X图形下工作,你可能有这样的经历:通过终端命令运行一个GUI程序,GUI界面出来了,但是你的终端还停留在原地,你不能在shell中继续执行其他命令了,除非将GUI程序关掉。
(./ur_command ${id};echo >&4 ) & # 在后台执行任务ur_command 并将任务 ${id} 赋给当前任务;任务执行完后在fd4种写入一个占位符 done <&4 # 指定fd4为整个for的标准输入 wait # 等待所有在此shell脚本中启动的后台任务完成 exec 4>&- # 关闭管道shell并发函数?
bash | Bourne Again SHell | 一种shell bg | BackGround | 用于将作业放到后台运行,使前台可以执行其他任务。该命令的运行效果与在指令后面添加符号&的效果是相同的,都是将其放到系统后台执行。 cal | CALendar | 用于显示当前日历,或者指定日期的日历。 cat | CATenate | “连接”,连接文件并打印到标准输出...
Putting it all together, you get something like “ls tried to open /dsafsda but couldn’t because it doesn’t exist.” This may seem obvious, but these messages can get a little confusing when you run a shell script that includes an erroneous command under a different name. ...
awk=“AhoWeibergerandKernighan”三个作者的姓的第一个字母bash=BourneAgainSHellbc=Basic(Better)Calculatorbg=BackGroundbiff=作者HeidiStettner在U.C.Berkely养的一条狗,喜欢对邮递员汪汪叫。cal=Calendar(日历)cat=Catenate(链接)cd=ChangeDirectorychgrp=ChangeGroupchmod=ChangeModechown=ChangeOwnerchsh=ChangeShellcmp...
If you’re familiar with Windows, the shell window will look something like a DOS command prompt; the Terminal application in OS X is essentially the same as a Linux shell window. 登录后,打开一个shell窗口(通常称为终端)。 在类似Gnome或Ubuntu Unity的图形界面中,最简单的方法是打开一个终端应用...