R
R
rmfalx2017-09-21 18:48:27
linux
rmfalx, 2017-09-21 18:48:27

How to run nosetests utility in cron?

I need a script written in python using Silenium to run once per minute.
I have autotest. It enters the site, performs an operation on the elements on the page, and exits. It is launched using the nosetests utility. The launch looks like this:
nosetests qwerty.py
test runs and I get a message

Ran 1 test in 8.293s

OK

I want the test to be run by cron 1 time per minute and here I ran into problems.
i wrote a bash script
#!/bin/bash
nosetests qwerty.py

and added execution to cron
*/1 * * * *     /home/xxx/PycharmProjects/AutoTest/features/nose_tests/12.sh > /tmp/qwert2.log 2>&1

I look at the logs and see that the command was not found. It turns out that if you enter the ipconfig command into the bash script, for example, it will give the same thing. Type must specify the full path to the utility. OK. I looked where nosetests is located
witch nosetests
/home/xxx/.local/bin/nosetests

I specify in the bash script
/home/xxx/.local/bin/nosetests qwerty.py
fucking does not work, now it writes
Traceback (most recent call last):
  File "/home/xxx/.local/bin/nosetests", line 7, in <module>
    from nose import run_exit
ImportError: No module named 'nose'

And then I understand that he cannot access the imported libraries along the way. How to be? This is the way he does not hawala
/usr/bin/python3 /home/xxx/.local/bin/nosetests /home/xxx/PycharmProjects/AutoTest/features/nose_tests/qlean_sms.py

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Mukovoz, 2017-09-21
@rmfalx

Why do you need a bash script if you can write it directly in the cron?
How do you execute a command in the console? Also, only with the full path you need to write to cron. And for every minute execution, you need not */1 * * * * , but like this * * * * *

* * * * * /usr/bin/nosetests /home/xxx/PycharmProjects/AutoTest/features/qwerty.py > /var/log/nosetests.log&

R
Rsa97, 2017-09-21
@Rsa97

At the beginning of the crontab file, you can define the necessary environment variables, such as PATH

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question