running cronjob using crontab on ubuntu linux


crontab

run.sh

cd /home/user/git/repo/python-demo
# key for crontab running
export PYTHONPATH=${PYTHONPATH}:/home/user/git/repo/
/home/user/anaconda3/bin/python run.py >> log/job.txt

crontab

sudo crontab -e
# every 5 minutes
*/5 * * * * /home/user/git/repo/python-demo/run.sh
  * * * * * command to be executed
  - - - - -
  | | | | |
  | | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
  | | | ------- Month (1 - 12)
  | | --------- Day of month (1 - 31)
  | ----------- Hour (0 - 23)
  ------------- Minute (0 - 59)

cronjob not running

see cronjob-not-running

export ENV in scripts for running crontab jobs successfully

Reference

History

  • 2020/1/17: created.

Author: kezunlin
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source kezunlin !
评论
  TOC