environment_variable = os.environ['TEST_ENV']
for line in fileinput.input('/etc/cron.d/cron-python', inplace=1):
    print(line.replace('XXXXXXX', environment_variable))
args = ['cron', '-f', '-L 15']
call(args)
Running cron python jobs within docker