cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
871
Views
5
Helpful
3
Replies

NSO Python script not running from root crontab

tcragg1
Cisco Employee
Cisco Employee

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?

1 Accepted Solution

Accepted Solutions

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.

View solution in original post

3 Replies 3

tsiemers1
Spotlight
Spotlight

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

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.

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.