小编Tia*_*opo的帖子

cassandra如何通过硬链接执行快照?

在这里阅读Cassandra文档,他们说如果启用JNA(Java Native Access)快照是通过硬链接执行的.

我无法理解硬链接如何能够保存给定文件的时间点版本,因为它是inode级别的文件本身(至少我理解硬链接的方式,我可能会弄错).

linux cassandra

7
推荐指数
1
解决办法
776
查看次数

为bash命令和函数实现超时的优雅解决方案

我编写了一个运行命令的函数,它以两个args为第一个命令,以秒为单位的第二个超时:

#! /bin/bash

function run_cmd {
    cmd="$1"; timeout="$2"
    grep -qP "^\d+$" <<< "$timeout" || timeout=10

    stderrfile=$(readlink /proc/$$/fd/2)
    exec 2<&-

    exitfile=/tmp/exit_$(date +%s.%N)
    (eval "$cmd";echo $? > $exitfile) &

    start=$(date +%s)
    while true; do
        pid=$(jobs -l | awk '/Running/{print $2}')
        if [ -n "$pid" ]; then
            now=$(date +%s)
            running=$(($now - $start))
            if [ "$running" -ge "$timeout" ];then
                kill -15 "$pid"
                exit=1
            fi
            sleep 1
        else
            break
        fi

    done 
    test -n "$exit" || exit=$(cat $exitfile)
    rm $exitfile
    exec 2>$stderrfile              
    return "$exit"
}


function …
Run Code Online (Sandbox Code Playgroud)

bash

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

标签 统计

bash ×1

cassandra ×1

linux ×1