0

i install redis-2.7.1 in my folder,and run my python code,it worked.

COMMON_MODEL_DIR="/data/aa/redis-2.7.1"
sys.path.append(COMMON_MODEL_DIR)
import redis

And when i set up crontab ,

*/10 1-23 * * * (cd /data3/aa/; python step.py 2 >> /data3/aa/2.log 2>&1)

But it won't worked it will report

Traceback (most recent call last):
  File "step.py", line 11, in ?
    import redis
  File "/data/aa/redis-2.7.1/redis/__init__.py", line 1, in ?
    from redis.client import Redis, StrictRedis
  File "/data/aa/redis-2.7.1/redis/client.py", line 157
    response = [nativestr(i) if i is not None else None for i in response]
                              ^
SyntaxError: invalid syntax

How will i fix it?

sundar nataraj
  • 8,524
  • 2
  • 34
  • 46
liumilan
  • 365
  • 1
  • 4
  • 13

1 Answers1

1

Obviously the user account under which your cron job is running is using another (and quite old) Python version that doesn't support ternary expressions. Find out which Python you are using and pass the full path in your crontab.

bruno desthuilliers
  • 75,974
  • 6
  • 88
  • 118
  • can you please help me with my question :- https://stackoverflow.com/questions/52712982/storing-data-into-redis-through-cron-job –  Oct 09 '18 at 03:40