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

Friday, April 1, 2016

OMNeT++/OMNEST priority schedule for the event at the same time

In OMNeT++/OMNEST, sometimes two events may arrive at the same time. However, the OMNeT++/OMNEST can only handle both events in sequence based on the arrival time of each event. If we hope to always handle a event before the other event, we can use the following function to handle this problem.

setSchedulingPriority(short p)

where p is the priority, the smaller number of p has higher priority.
refer to.
https://omnetpp.org/doc/omnetpp/api/classcMessage.html#a205278b4eaf8a54a901537f6e6cfae59


Examples:
cMessage *timer1 = new cMessage("tiemr1");
cMessage *timer2 = new cMessage("tiemr2");

timer1->setSchedulingPriority(1); // lower priority
timer1->setSchedulingPriority(-1); // high priority

send(timer1, Gate);
send(timer2, Gate);