scl enable python27 bash scl enable python27 bash bash bash

scl enable python27 bash


Doing everything in one heredoc in the SCL environment is the best option, IMO:

scl enable python27 - << \EOFcd /var/www/python/scripts/python runAllUpserts.py >/dev/null 2>&1EOF

Another way is to run just the second command (which is the only one that uses Python) in scl environment directly:

cd /var/www/python/scripts/scl enable python27 "python runAllUpserts.py >/dev/null 2>&1"


scl enable python27 bash activates a python virtual environment.

You can do this from within a bash script by simply sourcing the enable script of the virtual environment, of the SCL package, which is located at /opt/rh/python27/enable

Example:

#!/bin/bashcd /var/www/python/scripts/source /opt/rh/python27/enablepython runAllUpserts.py >/dev/null 2>&1


Isn't the easiest to just your python script directly? test_python.py:

#!/usr/bin/env pythonimport sysf = open('/tmp/pytest.log','w+')f.write(sys.version)f.write('\n')f.close()

then in your crontab:

2 * * * *    scl python27 enable $HOME/test_python.py

Make sure you make test_python.py executable.

Another alternative is to call a shell script that calls the python. test_python.sh:

#/bin/bashpython test_python.py

in your crontab:

2 * * * *   scl python27 enable $HOME/test_python.sh