-1
我是cronjob的新手。我想檢索目錄中的數據列表並將信息保存到我的模型中。django中的cronjob/task scheduler
這是我的代碼:
from os.path import getsize
import time
current_user = request.user
root = "/mnt/data/dashboard/"
for path, subdirs, files in os.walk(root):
for name in files:
file_name = name
size = getsize(root)
filepath = path
datastr = os.path.join(filepath,name)
files = datastr.replace("/mnt/data/dashboard/","")
date = time.ctime(os.path.getctime(root))
# insert = File(file=files, owner=current_user, _file_size=size, uploaded_at=date, original_filename=file_name, folder_id=6)
# insert.save()
try:
insert = File.objects.filter(original_filename = file_name)
except ObjectDoesNotExist:
insert = File(file=files, owner=current_user, _file_size=size, uploaded_at=date, original_filename=file_name, folder_id=6)
insert.save()
我應該做些什麼,使上述確保腳本是每天早晨的日常執行。如何設置cronjob /任務調度程序?
我認爲這是更容易..謝謝你..我會盡力 –
容易,但不完全因爲django腳本不是可執行文件 – e4c5
我可以在哪裏參考每一步? –