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