0

I have been trying to run a Python script that updates a Twitter bot and should run every day to make a post. I can run this without any problems conventionally using terminal (I'm on Mac) and I believe this cron job should work too:

30 10 * * * cd /Users/myname/documents/Python/fpltwitterbot && /Users/myname/opt/anaconda3/bin/python main.py

Nothing happens when the script is supposed to run, no tweet, no error message, nothing.

I have followed a tutorial and given cron and terminal permissions to be able to run properly so I'm very confused.

Any help is greatly appreciated thank you :D

kmurp62rulz
  • 169
  • 2
  • 9
  • What's the issue? – couka Jan 25 '21 at 13:30
  • sorry I've just done an update, because I forgot the issue, silly me. The issue is that nothing happens when the script is supposed to run and I was hoping to get help if my syntax or anything else is wrong here :) – kmurp62rulz Jan 25 '21 at 13:36
  • Its a PATH issue i guess. The main.py file is not registered in your path and therefore not found. Either add it to the path or add the full path to your cronjob: your/path/main.py – Sh0rtey Jan 25 '21 at 13:45

1 Answers1

0

Well, I don't know what your problem is but, I guess you did't set the PATH.

Try this,

  1. Run printenv | grep "PATH". (check your PATH)
  2. Add PATH to your crontab
PATH=/your/path

*/1 * * * * your_command

P.S
You can get a log from python script like
Users/myname/opt/anaconda3/bin/python main.py >> /log/file/path 2>&1

JaeHwanLim
  • 36
  • 5