dimanche 14 mars 2021

Cron-based terminal job doesn't start until screen unlocked (sometimes)

I have a cron job whose command line looks like:

30 5 * * * osascript -e 'tell application "Terminal" to do script "bash-script-file"'

FWIW the base script file sets some environment variables and then runs a Ruby program.

Prior to last week, most days this ran just fine, but occasionally (~ twice/month) it would hang until I either unlocked the screen or attached remotely to the system. At that time I would see a terminal screen with a message about new mail and a command line prompt with the bash-script-file on it. At that point, I could wait and the script would proceed to run normally. I have checked System Settings and the computer is set to sleep never. I'm not locking the screen (instead allowing it to go to sleep), and of course I have the screen saver locked, requiring a password to wake up.

Last week (about five days ago), I added a second cron job of the same form (running another bash script that started another Ruby program), and since then, both jobs have hung every day until I attached remotely. What is causing this? What can I do to resolve it?

tl;dr cron-scheduled terminal jobs are hanging until the screen unlocks.

Aucun commentaire:

Enregistrer un commentaire