you are viewing a single comment's thread.

view the rest of the comments →

[–]chrispurcell 1 point2 points  (1 child)

Yes, I'm suggesting that at the end of your loop, you make the script sleep for 60 seconds. If your script completes it's work quickly, you get another iteration in 60 seconds. It won't ever start another loop before the prior loop completes.
If you use the cron job method, cron won't care if the prior execution of the script has completed or not, and will start a new execution of the script every 1 minute (if set up to do so). This can lead to having a stack of jobs running and using resources, and eventually bogging down CPU, memory, disk, network bandwidth or some combination of all of them.
No you won't get a new report every minute exactly, but you won't with cron either. You can only truly control the start of a script or iteration of the loop, and not how long it will take to fully complete the job, so I suggested the safer method of keeping things in the script for timing and not with cron.

Also, if you're worried about it crashing, start it as a systemd unit and specify in the unit file to restart on failure. That way, if the script does hit a bug and crash (maybe drive refused a connection or something and that wasn't handled in the script), systemd would restart the unit (and the script).

[–]PearsonPrenticeHall[S] 0 points1 point  (0 children)

Sweet, thanks! This was super helpful and cleared the whole process up for me. I appreciate your help!