had this bizarre issue where a backup script ran fine monday through friday but failed every saturday. took me way too long to figure out.

turns out the script was calling an internal API that had rate limiting. during the week, the backup ran at 2am when nobody was using the system. on saturdays, some other batch process kicked off at the same time and ate up all the API quota.

the fix was dead simple — stagger the start time by 30 minutes. but finding the cause? that was a couple hours of my life I’m not getting back.

moral of the story: if your cron job is failing intermittently, check what else runs at the same time. crontab -l only shows YOUR crontab. other users and system crontabs in /etc/cron.d/ might be competing for the same resources.

  • ultimaluz@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    34 minutes ago

    not weekends but I had one that failed on two random days in a month and looked totally fine the rest. it’s a scheduled job that reads a couple of sites through a logged in browser on my laptop, and those two days the browser just wasn’t connected, so the job ran on time and had nothing to read. the log said “ok, nothing new” which is the worst kind of failure lol. now it uses a browser that keeps its own session and the other one only as fallback, and an empty result gets reported as a failure and not as a quiet day. same lesson as yours I guess, check what else has to be alive at that moment, not only what’s running

  • Jayjader@jlai.lu
    link
    fedilink
    arrow-up
    1
    ·
    1 hour ago

    I was just reading an article today about how now that there’s more and more uninterruptible power supplies plugged into the grid, notably with all the data centers that were built over the last 20 years, the grid itself experiences a similar disturbance ever minute as all the factory-default-configured systems pulse to check their internal battery state.

    The article concluded with “the simplest fix would be to stagger/randomize the default check times, but how can we encourage manufacturers to do so?”

  • who@feddit.org
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 hours ago

    It’s common practice to stagger cron jobs to run at different offsets from the hour. This can mitigate load spikes, both local and remote.

  • bajabound@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    7 hours ago

    I have a cron job that has been failing since I added it. I’ll get around to fixing it at some point.

  • Ctrl Zee@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    9 hours ago

    Loved the replies. Once it’s over (that’s the hard part), everyone has a funny story to tell!

    Mine was a race condition in an outsourced core system that showed up about six months after release, only when enough transactions hit at the same moment. The contact centre was on fire, with people calling non-stop.

    Same lesson as yours: when something fails only sometimes, stop staring at the code and look at what else is running at that moment.

  • Elvith Ma'for@feddit.org
    link
    fedilink
    arrow-up
    2
    ·
    7 hours ago

    We had a pipeline suddenly fail everytime when it ran on its weekly schedule but all manual triggers were OK.

    After a few weeks we learned that the Linux admins had moved the weekly patch window of the runners to exactly the time our schedule ran the pipeline and this caused all kinds of unpredictable problems.

    We then moved the scheduled time and since then the pipeline runs without a hitch

  • exu@feditown.com
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    3 hours ago

    That’s why I uses systemd timers with RandomizeDelay. Spreads the load a bit