eric@eric:~/project$ tree -d
.
|-- env
| |-- bin
| |-- include
| | `-- python3.4m -> /usr/include/python3.4m
| `-- lib
| `-- python3.4
| |-- collections -> /usr/lib/python3.4/collections
| |-- config-3.4dm-x86_64-linux-gnu -> /usr/lib/python3.4/config-3.4dm-x86_64-linux-gnu
| |-- config-3.4m-x86_64-linux-gnu -> /usr/lib/python3.4/config-3.4m-x86_64-linux-gnu
| |-- distutils
| | `-- __pycache__
| |-- encodings -> /usr/lib/python3.4/encodings
| |-- importlib -> /usr/lib/python3.4/importlib
| |-- lib-dynload -> /usr/lib/python3.4/lib-dynload
| |-- plat-x86_64-linux-gnu -> /usr/lib/python3.4/plat-x86_64-linux-gnu
| |-- __pycache__
| `-- site-packages
| ... # removed thirdparty libraries just to make it more readable
| |-- pip-1.5.6.dist-info
| |-- __pycache__
| |-- setuptools
| | |-- command
| | | `-- __pycache__
| | |-- __pycache__
| | `-- tests
| | `-- __pycache__
| `-- setuptools-3.6.dist-info
`-- myscript.py
so in home directory there is a folder named project. in project folder I have a virtualenv folder and a simple script(let's say hello world in python3)
which python3 gives /usr/bin/python3
Now I'm trying to run this script using crontab -e (ubuntu 14.04).
I can run this script manually by activating virtualenv (source env/bin/activate) but I've no idea how should I do this thing in crontab and what would be the shebang for this python3 virtualenv.
PS: I'm able to run a python2 script in crontab by adding this shebang #!/usr/bin/python at top of the file and then this line in crontab -e (run everyday at 2PM )
00 14 * * * /usr/bin/python /home/eric/project/myscript.py >> /var/log/cronjob.log
PPS: I dont want to write setup.py and use setuptools just a natural way (as I did above for python2)
/path/to/env/bin/python /path/to/script.py ...?