Script fail in cron but works in command line "keyring error"

298 views Asked by At

Hello I have created a python script and wanted to execute it daily with crontab.

I want to execute it on an "Ubuntu server" (basically an old latop that use ubuntu desktop 20.04.2.0 but I always keep him close and log into it with ssh mainly)

In this script I use yagmail to informe myself when the script finished running. I does work when using the command line. But when I use cron it doesn't work.

I'm a newbie so I have a hard time understanding why it doesn't work. To try to debug it I redirected the output of the script into a log file and this is what I get:

    File "/usr/lib/python3/dist-packages/keyring/core.py", line 63, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/usr/lib/python3/dist-packages/keyring/backends/fail.py", line 25, in get_password
    raise NoKeyringError(msg)
keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details

I have tried scooting the internet but didn't find anything interesting/ that I could understand.

I have tried running the crontab in user/su. Nothing works,same error.

If you have any idea or lead that I could follow it would be great Thanks!

1

There are 1 answers

0
Hectobros On

Solved the issue by using oauth2 to log in with yagmail. works great with crontab. Still no idea on how to use the keyring with crontab thoe.