2

I want to run sudo airodump-ng -w myfile every ten minutes or so, for m minutes. It does not matter if the running time shifts (that it, if it runs m minutes later each time).

Notice that this is a monitoring program, which won't just output and exit. I suppose the solution for this one question is also valid for similar monitoring programs.

I was thinking about putting something like:

*/10 * * * * airodump-ng mon0 -w myfile

into crontab. There is no need to change the myfile name, airodump can correctly check whether myfile exists and create a myfile-02 and so on.

However, how should I stop it running after s secs? pkill airodump is the only thing I can think of. Is this the best for running it 1 minutes twice an hour?

20,40 * * * * airodump-ng mon0 -w myfile

21,41 * * * * pkill airodump-ng

4

Don't use pkill. Instead, run your app under the timeout command from the coreutils package:

*/10 * * * * timeout 5m airodump-ng mon0 -w myfile

(Where here 5m means to run for 5 minutes.) Use --signal if you need something other than TERM.

0
NEXT_WAIT_TIME=0
until command || [ $NEXT_WAIT_TIME -eq 4 ]; do
   sleep $(( NEXT_WAIT_TIME++ ))
done

or as one liner

NEXT_WAIT_TIME=0; until command || [ $NEXT_WAIT_TIME -q 4 ]; do sleep $(( NEXT_WAIT_TIME++ )); done

source: https://stackoverflow.com/a/12321815/3648121

2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – jasonwryan Sep 22 '15 at 18:15
  • Added more information, how ever the answer @mattdm gave is way beter. – Jazula Sep 22 '15 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.