小编Nab*_*ham的帖子

将 tmux 命令从远程内部 ssh 会话发送到本地实例

目标是从远程服务器向本地运行的 tmux 发送 tmux 命令。不要运行到不同的 tmux 实例。

在 tmux 中,我们通过 ssh 连接到不运行 tmux 的服务器

local>tmux send-key C-p  # works
local>ssh user@remote
user@remote> tmux send-key C-p # this will try to find tmux instance on remote. but we want to send it the local instead.
Run Code Online (Sandbox Code Playgroud)

我不能使用键绑定,因为这将从内部脚本运行。

ssh tmux

5
推荐指数
1
解决办法
804
查看次数

不使用 Linux 交换,即使操作系统内存不足

交换使用率低,操作系统有时会耗尽内存并开始破坏进程

swapon -s 

Filename                                Type            Size    Used   Priority
/dev/vda1                               partition       2047992 75030       1
Run Code Online (Sandbox Code Playgroud)

内存使用率约为 97%。知道出了什么问题吗?我尝试关闭/打开交换,但没有帮助。 v

Centos 6.5 / 内核 2.6.32

cat /proc/meminfo

MemTotal:       15000800 kB
MemFree:          300532 kB
Buffers:           11364 kB
Cached:           211224 kB
SwapCached:            0 kB
Active:         12613992 kB
Inactive:        1854012 kB
Active(anon):   12555272 kB
Inactive(anon):  1690320 kB
Active(file):      58720 kB
Inactive(file):   163692 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       2047992 kB
SwapFree:        2047992 kB
Dirty:                68 kB
Writeback:             0 kB
AnonPages:      14245460 kB
Mapped:            19440 kB …
Run Code Online (Sandbox Code Playgroud)

memory centos swap

5
推荐指数
1
解决办法
1万
查看次数

bash if 语句在 crontab 作业中出现意外行为

这是脚本

bash --version | head -n1
if [ "$1" == "now"  ]
then
    echo if now
    execut job
else
    echo else "_"$1"_"  # make sure we are not picking any spaces
    if [ condition  ]
    then
    execut something else
    fi
fi

./script now
if now
Run Code Online (Sandbox Code Playgroud)

如果从交互式 shell 运行,则按预期工作。但是,如果从 cron as 调用,则 if 会转到 else 块

* * * * *   root    /home/user/./script now >> /tmp/log
cat /tmp/log
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
else _now_
Run Code Online (Sandbox Code Playgroud)

也与“-eq”相同。

我是否因为没有吃早餐而错过了一些非常简单的事情?

运行 Ubuntu 14.04LTS。

linux shell bash cron conditional

4
推荐指数
1
解决办法
1215
查看次数

标签 统计

bash ×1

centos ×1

conditional ×1

cron ×1

linux ×1

memory ×1

shell ×1

ssh ×1

swap ×1

tmux ×1