Skip to content

Instantly share code, notes, and snippets.

@jal-tw
jal-tw / shell-script_with_lock_and_pid.sh
Created December 19, 2017 10:33
C shell script, lock file, pid, check process alive
#!/bin/sh
name="shell-script"
now=`/bin/date`
echo "Starting at ${now}."
LOCKFILE="/var/run/${name}.lock"
if [ -f ${LOCKFILE} ]
then
# --zero-speed=1000000000 for 1000Mbps
# --zero-speed=100000000 for 100Mbps
cfgmaker --snmp-options=:::::2 --global "WorkDir: /usr/local/www/data/html/mrtg/172.16.1.1" --global "Options[_]: growright, bits" --global "Language: big5" --global 'AddHead[_]:<script type="text/javascript" src="//jal.tw/google_analytics.js"></script>' --zero-speed=1000000000 --show-op-down --if-filter='$if_type!=1 && $if_type!=53 && $if_type!=24 && $if_type!=131 && $if_type!=135 && $if_type!=136 && $if_type!=137 && $if_type!=142 && $if_type!=150 && $if_type!=217 && $if_type!=218 && $if_type!=222 && $if_type!=223' community_readonly@172.16.1.1 --output=172.16.1.1.cfg
# -i in-place edit, only work for GNU sed, not portable.(直接改原始檔案,僅支援 GNU sed,跨平台有可能會失效)
/usr/bin/sed -i '' -e 's/iso-8859-15/big5/g' */*/index.html
/usr/bin/sed -i '' -e '/Command line/d' */*/index.html
/usr/bin/sed -i '' -e '/Command-Line/d' */*/index.html
/usr/bin/sed -i '' -e '/commandline/d' */*/index.html
/usr/bin/sed -i '' -e '/HTTP-EQUIV="Expires"/d' */*/index