CronJob not running

前端 未结 11 1082
攒了一身酷
攒了一身酷 2020-11-22 02:33

I have set up a cronjob for root user in ubuntu environment as follows by typing crontab -e

  34 11 * * * sh /srv/www/live/CronJobs/daily.sh
  0          


        
11条回答
  •  误落风尘
    2020-11-22 02:37

    Finally I found the solution. Following is the solution:-

    1. Never use relative path in python scripts to be executed via crontab. I did something like this instead:-

      import os
      import sys
      import time, datetime
      
      CLASS_PATH = '/srv/www/live/mainapp/classes'
      SETTINGS_PATH = '/srv/www/live/foodtrade'
      sys.path.insert(0, CLASS_PATH)
      sys.path.insert(1,SETTINGS_PATH)
      
      import other_py_files
      
    2. Never supress the crontab code instead use mailserver and check the mail for the user. That gives clearer insights of what is going.

提交回复
热议问题