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 myfileinto 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 myfile21,41 * * * * pkill airodump-ng
Run and stop a monitoring command as sudo for s seconds every m minutes
cron;sudo;monitoring;timeout
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.