crontab is often used in Linux systems to perform automation jobs.

Crontab

crontab -l # list crontab jobs
crontab -e # edit crontab jobs
20 10 * * * cd /project/my_project/ && /opt/pythonhome/env/python3/bin/python3.7 /project/my_project/run.py >> /project/my_project/log/run.log 2>&1

Note

  • This job will run at 10:20 everyday.
  • First it will enter the project path just in case your code contains relative path like ./path/file.extension
  • Use absolute path for your python- it will also export the log to ./log/run.log

Resources