之间有什么区别
$ nohup foo
Run Code Online (Sandbox Code Playgroud)
和
$ foo &
Run Code Online (Sandbox Code Playgroud)
和
$ foo &
$ disown
Run Code Online (Sandbox Code Playgroud) 有一个内置的 Unix 命令,repeat它的第一个参数是重复命令的次数,其中命令(带有任何参数)由 的其余参数指定repeat。
例如,
% repeat 100 echo "I will not automate this punishment."
Run Code Online (Sandbox Code Playgroud)
将回显给定的字符串 100 次,然后停止。
我想要一个类似的命令——让我们称之为forever——它的工作原理类似,除了第一个参数是重复之间暂停的秒数,它会永远重复。例如,
% forever 5 echo "This will get echoed every 5 seconds forever and ever."
Run Code Online (Sandbox Code Playgroud)
我想我会在写之前问这样的事情是否存在。我知道它就像一个 2 行的 Perl 或 Python 脚本,但也许有更标准的方法来做到这一点。如果没有,请随时用您喜欢的脚本语言发布解决方案。
PS:也许更好的方法是将repeat重复次数(-1 表示无穷大)和重复之间的睡眠秒数进行概括。上面的例子将变成:
% repeat 100 0 echo "I will not automate this punishment."
% repeat -1 5 echo "This will get echoed every 5 seconds forever."
Run Code Online (Sandbox Code Playgroud) 我经常在网上看到用不同符号连接各种命令的教程。例如:
command1 | command2
command1 & command2
command1 || command2
command1 && command2
Run Code Online (Sandbox Code Playgroud)
其他人似乎将命令连接到文件:
command1 > file1
command1 >> file1
Run Code Online (Sandbox Code Playgroud)
这些是什么?他们叫什么?他们在做什么?还有更多吗?
到目前为止,我真的找不到任何东西,但是真的curl没有真正超时吗?
user@host:~# curl http://localhost/testdir/image.jpg
Run Code Online (Sandbox Code Playgroud)
我之所以这么问是因为我testdir将对图像的任何请求重定向到一个单独的 Apache 模块,该模块会动态生成这些图片。图片可能需要长达 15 分钟才能真正准备好并交付给提出请求的客户。
会curl一直等待(或者它取决于配置)还是有任何超时?
我需要从 shell 脚本中找到我的外部 IP 地址。目前我使用这个功能:
myip () {
lwp-request -o text checkip.dyndns.org | awk '{ print $NF }'
}
Run Code Online (Sandbox Code Playgroud)
但这取决于perl-libwww, perl-html-format,perl-html-tree已安装。我可以通过哪些其他方式获得我的外部 IP?
我想要一个这样的shell脚本:
my-app &
echo $my-app-pid
Run Code Online (Sandbox Code Playgroud)
但是我不知道如何获取刚刚执行的命令的pid。
我知道我可以只使用jobs -p my-app命令来grep pid。但是如果我想多次执行shell,这个方法就行不通了。因为工作规范是不明确的。
我刚刚用 Ubuntu Oneiric 11.10 设置了一台新机器,然后运行
apt-get update
apt-get upgrade
apt-get install git
Run Code Online (Sandbox Code Playgroud)
现在如果我运行git --version它告诉我我有git version 1.7.5.4但在我的本地机器上我有更新的git version 1.7.9.2
我知道我可以从源代码安装以获得最新版本,但我认为尽可能多地使用包管理器来保持一切标准化是一个好主意。
那么是否可以使用apt-get来获取更新版本的git,正确的方法是什么?
的wheel在* nix计算机组通常是指基团与某种根状的访问。我听说在某些 *nix 上它是有权运行的用户组su,但在 Linux 上似乎是任何人(尽管您自然需要 root 密码)。在我使用的 Linux 发行版上,它似乎是默认情况下有权使用的组sudo;他们有一个条目sudoers:
%wheel ALL=(ALL) ALL
Run Code Online (Sandbox Code Playgroud)
但这都是切线的。我的实际问题是:为什么叫这个组wheel?之前听过各种解释,不知道对不对。有谁知道这个词的实际历史?
有时,当您有几场 RAM 时,以千字节为单位查看 meminfo 并不舒服。在 Linux 中,它看起来像:

这是它在 Mac OS X 中的样子:

有没有办法在 Linux top 中以 TB、GB 和 MB 显示 meminfo?
我已配置sudo为无需密码即可运行,但是当我尝试时ssh 'sudo Foo',仍然收到错误消息sudo: sorry, you must have a tty to run sudo。
为什么会发生这种情况,我该如何解决?