S
S
stayHARD2015-07-24 20:16:15
Python
stayHARD, 2015-07-24 20:16:15

How to add a task to crontab?

Hello.
There is a script written in Python.
It needs to be run, for example, every minute.
It lies in the /home/ubuntu/shopify/
folder. This folder contains:
/shop.py
/client_secrets.json
/env - a virtual environment in which the supplied dependencies are required to run.
The test.py file takes some data from example.txt.
I do:
sudo crontab -e
In the log I get:

Traceback (most recent call last):
  File "/home/ubuntu/shopify/shop.py", line 18, in <module>
    scope='https://www.googleapis.com/auth/bigquery')
  File "/home/ubuntu/shopify/env/local/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/ubuntu/shopify/env/local/lib/python2.7/site-packages/oauth2client/client.py", line 2064, in flow_from_clientsecrets
    client_type, client_info = clientsecrets.loadfile(filename, cache=cache)
  File "/home/ubuntu/shopify/env/local/lib/python2.7/site-packages/oauth2client/clientsecrets.py", line 155, in loadfile
    return _loadfile(filename)
  File "/home/ubuntu/shopify/env/local/lib/python2.7/site-packages/oauth2client/clientsecrets.py", line 115, in _loadfile
    raise InvalidClientSecretsError('File not found: "%s"' % filename)
oauth2client.clientsecrets.InvalidClientSecretsError: File not found: "client_secrets.json"

My job:
*/1 * * * * /home/ubuntu/shopify/env/bin/python /home/ubuntu/shopify/shop.py > /home/cronlog.txt 2>&1

Why does he not see the file if it is nearby?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lega, 2015-07-24
@lega

Apparently the launch folder is different, you can go to the desired folder before launching:

*/1 * * * * cd home/ubuntu/shopify; /home/ubuntu/shopify/env/bin/python /home/ubu...
Or you can make this transition in the py file that is being launched.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question