# Articles/Tips about Linux

# Tips

Test Tor Available:

curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs
1

Check git remote updated or not (See stackoverflow):

cd /path/to/repo
if git fetch origin master &&  [ `git rev-list HEAD...origin/master --count` -gt 0 ] && git merge origin/master
then 
    # do something here
    yarn build
fi
1
2
3
4
5
6

Shell lock file, See Stackoverflow:

LOCK=/tmp/mysh.lock
LOG=/tmp/mysh.log
if [ -f ${LOCK} ] && [ -e ${LOCK} ] && kill -0 `cat ${LOCK}`; then
        echo `date` 'altready running' >> ${LOG}
        exit
fi

trap "rm -f ${LOCK}; exit" INT TERM EXIT

echo $$ > $LOCK
echo "running mysh.sh" > ${LOG}

# do something here, for example
yarn build

rm -f $LOCK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Last Updated: 3/17/2020, 3:11:20 AM