11-01-2022 05:23 AM
I am trying to run a python script through the root crontab on a VM that hosts a system-install of NSO. The script relies on the ncs python module, and works correctly when executed directly through the CLI, both from my own user account and after doing a sudo su to root. However, when run using the root crontab, the script fails due to not being able to import the ncs module.
Since this is a system-install and not a local-install, shouldn't the ncs module already be in the path, or have I misunderstood?
Solved! Go to Solution.
11-04-2022 12:35 AM
Hello,
I think the issue is coming from the fact you have some env variable missing( PYTHONPATH ) when it’s executing your command . Here a Link that might help you.
11-01-2022 07:12 AM
Is it trying to use a different version of python than your shell? Could try setting the path to the correct version where ncs module lives
#!/usr/bin/python3
or
30 00 * * * /usr/local/bin/python3.X /path/to/script.py
11-01-2022 07:39 AM
No, I specified the full path to the python binary in the crontab entry.
0 4 * * * /bin/python3 /home/tcragg/remove_keeper_duplicates.py
If I run "/bin/python3 /home/tcragg/remove_keeper_duplicates.py" directly on the CLI, it works.
11-04-2022 12:35 AM
Hello,
I think the issue is coming from the fact you have some env variable missing( PYTHONPATH ) when it’s executing your command . Here a Link that might help you.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide