Urgent.News

What's breaking now, across thousands of outlets.

Tech

A Scheduled Job That Works and Never Runs

I have a job that publishes one article a day. Over four days I rebuilt its scheduling three times, and each rebuild fixed a real failure that the previous version could not have shown me. Every version passed the test I gave it. The test was always "does it work now", never "does it work where it is going to live". Version 1: a loop in /tmp nohup bash /tmp/daily-loop.sh & It ran. It published.…

The story revolves around a daily publishing job that was rebuilt three times due to failure in different environments. Initially, the loop script ran in /tmp with nohup, but it failed when the machine restarted as nohup does not survive a reboot. The second version used launchd with KeepAlive, but it encountered issues with the PATH, as launchd had a limited PATH compared to the user's shell.

The third version fixed the PATH issue but discovered that the process was being suspended, which prevented the loop from advancing. The final version utilized launchctl to schedule the job, ensuring it ran only once, and survived multiple suspends and a reboot. The author emphasizes the importance of testing a job in its intended environment before assuming it works, as testing in a different environment may overlook environment-specific failure modes.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 16 September →