Score:1

Crond Inactive Every Other Minute

zw flag

I have a problem with crond (dated 13Feb21) on my Slackware 14.2 x86_64 (Linux version 5.12.10) server.

I have a script that crond runs every minute that accesses an external device for current data and logs it to a file. I will call the script Script1, and it runs fine.

I also have anther script that runs every minute and it processes a file that is larger in size each time the script runs. As result the script takes longer to run each time as well. This script also runs fine, and I will call it Script2. The two scripts are not related and there are no files shared between the two scripts.

Recently I noted Script1 was only logging the data to the data file every other minute instead of every minute. I finally traced the problem and I am not sure if is a real solvable problem, or a misconception on my part on how crond works.

When the file being processed by Script2 becomes large enough, the script takes more than a minute to run. Using “crond –l debug” to monitor what crond was doing, it appears that if Script2 is still running at the beginning of the next minute, it does not start Script1, so no data is logged. Even stranger however, is that there are several other scripts that should run every minute and they do not start as well.

I was under the impression that crond looked at what is scheduled to run at the present moment in time and disregarded any past scheduled tasks. What appears to be happening now is that if a script is still running at the next minute, it does not do anything for that whole next minute. When crond is running in debug mode, the cron log shows absolutely no activity for the entire subsequent minute. It is only at the next following minute when Script2 is no longer running, that crond activity returns to normal.

Can someone enlighten me as to what is going on?

Thanks

Romeo Ninov avatar
in flag
W/o the scripts we can't do much. Unfortunately the crystal ball is on dry cleaning.
Score:0
zw flag

After many hours of searching, I came across a post where a user had a problem that was solved by using "#!/bin/bash" as the shebang instead of "#!/bin/sh". Not knowing for sure which one I had used, and grasping for straws, I checked my script that was causing the problem. What I found was that in one of my last edits I must have inadvertently hit the space bar at some point because my shebang read "#! /bin/bash". It didn't affect the way the script ran, but it sure messed with crond. All is well now, but it won't be a lesson I will soon forget. Perhaps this will save another user from similar grief down the road.

djdomi avatar
za flag
Questions seeking installation, configuration or diagnostic help must include the desired end state, the specific problem or error, sufficient information about the configuration and environment to reproduce it, and attempted solutions. Questions without a clear problem statement are not useful to other readers and are unlikely to get good answers Moreover without the script it's not a useful question atm imho
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.