I'm setting up some shell scripting to be executed every five minutes, then every minute on our client's system, to poll a log and pull some timing information to be stored and accessed by another application through an external file. The current implementation we have in place works fine as it writes a single line to two separate files. We're refining the process so now I need to write two lines to one file every five minutes, and four lines to another, for every minute. However, I've noticed in testing that every few minutes the lines seem to execute out of order.
My scripts are included below:
*/5 * * * * ~/myscript.pl ~/mylog | tail -3 | head -1 > ~/myreport1
*/5 * * * * ~/myscript.pl ~/mylog | tail -2 | head -1 >> ~/myreport1
* * * * * ~/myscript.pl ~/mylog | tail -8 | head -1 > ~/myreport2
* * * * * ~/myscript.pl ~/mylog | tail -7 | head -1 >> ~/myreport2
* * * * * ~/myscript.pl ~/mylog | tail -3 | head -1 >> ~/myreport2
* * * * * ~/myscript.pl ~/mylog | tail -2 | head -1 >> ~/myreport2
In some cases, it seems that only a handful of the lines execute properly while in others, only one line is written. I don't even see the full number of lines written to the file all the time, otherwise I'd just assume the values I was pulling weren't being collected properly. I'm not sure how to judge whether all the cron lines are being executed, and what could be causing them to happen out of order, or not at all.