我可以同时将输出重定向到日志文件和后台进程吗?
换句话说,我可以做这样的事情吗?
nohup java -jar myProgram.jar 2>&1 > output.log &
Run Code Online (Sandbox Code Playgroud)
或者,这不是合法的命令吗?或者,我是否需要手动将其移动到后台,如下所示:
java -jar myProgram.jar 2>$1 > output.log
jobs
[CTRL-Z]
bg 1
Run Code Online (Sandbox Code Playgroud) 我正在尝试从已执行命令的输出中执行 IF 语句。这是我尝试这样做的方法,但它不起作用。有谁知道正确的方法来做到这一点?
if [ "`netstat -lnp | grep ':8080'`" == *java* ]; then
echo "Found a Tomcat!"
fi
Run Code Online (Sandbox Code Playgroud) 我问这个问题是因为,虽然互联网上有很多答案表明这who -a是一个选项,但没有人解释如何阅读输出。如果您可以提供一个指向解释这一点的在线网站的链接,那同样是一个很棒的答案。这是我想破译的一个例子:
[bo@hostname ~]$ who -a
Jun 17 03:47 590 id=si term=0 exit=0
system boot Jun 17 03:47
run-level 3 Jun 17 03:47 last=S
Jun 17 03:48 4424 id=l3 term=0 exit=0
LOGIN tty1 Jun 17 03:48 5503 id=1
LOGIN tty2 Jun 17 03:48 5504 id=2
LOGIN tty3 Jun 17 03:48 5505 id=3
LOGIN tty4 Jun 17 03:48 5506 id=4
LOGIN tty5 Jun 17 03:48 5507 id=5
LOGIN tty6 Jun 17 03:48 5508 id=6
pts/0 Oct 19 16:27 15250 …Run Code Online (Sandbox Code Playgroud) 当我用 pip 安装这个“Taurus Blazemeter 'bzt'”程序时,它最终被安装到~/.local/bin 文件夹中。
mkdir ~/bzt && cd ~/bzt
sudo apt-get install python default-jre-headless python-tk python-pip python-dev libxml2-dev libxslt-dev zlib1g-dev
sudo pip install bzt
Run Code Online (Sandbox Code Playgroud)
有谁知道这个~/.local文件夹的用途以及为什么会安装这样的 Python 程序?
我可以在提示显示GIT时,当前目录有/包含一个.git文件夹?有没有办法做到这一点?我当前的提示定义如下:
export PS1="[\u@\h] \w $ "
Run Code Online (Sandbox Code Playgroud)
所以,我的提示是这样的:
[user@computer] ~/workspace $
Run Code Online (Sandbox Code Playgroud)
我希望它动态地看起来像这样:
[user@computer] ~/workspace GIT $
Run Code Online (Sandbox Code Playgroud) 红帽从何而来?它是直接源自 Linus Torvaldis linux 发行版(2 年前)还是起源于 BSD 或 System-V??我只是想知道如何在Linux世界中对Redhat进行分类。
1991
Linus Torvalds releases the Linux® kernel.
1993
Bob Young incorporates ACC Corporation, a catalog business
that sells Linux and UNIX software accessories and books,
and distributes a magazine called New York UNIX.
1994
Marc Ewing creates his own distribution of Linux, which he
names Red Hat® Linux. Released in October, it becomes known
as the Halloween release.
Run Code Online (Sandbox Code Playgroud)