Monday, September 25, 2017

PDF 處理工具 pdftk in CentOS 7

下載篇:
https://www.linuxglobal.com/pdftk-works-on-centos-7/

指令篇:
http://seisman.info/introduction-to-pdftk.html

Friday, September 22, 2017

install FTP in CentOS

Refer to
http://luyaku.pixnet.net/blog/post/188199646-vsftpd%EF%BC%9Aftp-server-%E5%AE%89%E8%A3%9D%E8%88%87%E8%A8%AD%E5%AE%9A

install Samba 4.4.4 in CentOS

yum --nogpgcheck localinstall samba-common-libs-4.4.4-14.el7_3.x86_64.rpm samba-libs-4.4.4-14.el7_3.x86_64.rpm samba-common-tools-4.4.4-14.el7_3.x86_64.rpm libsmbclient-4.4.4-14.el7_3.x86_64.rpm samba-client-4.4.4-14.el7_3.x86_64.rpm samba-4.4.4-14.el7_3.x86_64.rpm libwbclient-4.4.4-14.el7_3.x86_64.rpm samba-client-libs-4.4.4-14.el7_3.x86_64.rpm samba-common-4.4.4-14.el7_3.noarch.rpm


CentOS 7更新後的暫純檔位置

/var/cache/yum/x86_64/7/updates/packages

Friday, September 8, 2017

ouput the standard output to variable

1. 引入library
import subprocess

2. 定義函數
def get_cmd_line_results(input_string):
    os.chdir(INET_DIR)
    proc = subprocess.Popen(input_string, stdout=subprocess.PIPE, shell=True)
    #"git symbolic-ref HEAD"
    (out, err) = proc.communicate()
    os.chdir(CUR_DIR)
    return out[:-1]



3. 在主程式內容呼叫
inet_branch = get_cmd_line_results("git symbolic-ref HEAD")

Tuesday, August 29, 2017

crontab usage rule in Linux

1. create new crontab task:
crontab -e
https://code.kpman.cc/2015/02/11/%E5%88%A9%E7%94%A8-crontab-%E4%BE%86%E5%81%9A-Linux-%E5%9B%BA%E5%AE%9A%E6%8E%92%E7%A8%8B/

2. delete crontab task text in "crontab -e":
crontab -r
3. lookup current crontab task in "crontab -e":
crontab -l
4. delete on-going crontab task:
ps -o pid,sess,cmd afx
For example:
(4-1) find the task executed by cron:
 88588  88588 /usr/sbin/crond -n
160149  88588  \_ /usr/sbin/crond -n
134979  88588  \_ /usr/sbin/CROND -n
134982 134982      \_ /bin/sh -c python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1 > ~/run_11ax_txop.log
134984 134982      |   \_ python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1
170760 134982      |       \_ sh utility_script/vector_filter_fast.sh results/dntp-4STAs-11ax-AMSDU-UDP-AlgoA-4A0B-TXOP-4NSS-4.vec resul ...

(4-2) crontab start executing a python script, you can kill this python script task by
kill -9 134984 

ref: https://superuser.com/questions/232144/how-to-stop-a-currently-running-cron-job/834110