-When I try to read the file uploaded by Django and use cron to perform some operation, a permission error occurs if the file cannot be read. -The authority when uploading a file is "600"
As a prerequisite, it is an environment that requires administrator privileges when performing chmod.
os.py
import os
os.system('sudo shmod 644 path')
python os.py
-> Switch permissions.
Run with cron-> without switching permissions.
subprocess.py
import subprocess
subprocess.call('sudo shmod 644 path')
python subprocess.py
-> Switch permissions.
Run with cron-> without switching permissions.
By writing "FILE_UPLOAD_PERMISSIONS = 0o644" in settings.py, the permission of the uploaded file became "644". It seems that the default is "600" in consideration of security, but it took time. ..
I don't know why it didn't switch in subprocess or os.system when I cron it.
Recommended Posts