스크립트는 센서에서 파일로 온도를 쓰는 두 개의 python 스크립트를 먼저 실행 한 다음 .sh 파일 내에서 ftp를 통해 업로드합니다.Crontab은 스크립트의 일부만 실행합니다.
.sh 파일을 수동으로 실행할 때만 온도가 업데이트됩니다. crontab이 스크립트를 실행할 때 ftp 만 업로드하지만 take_pic.py를 제외하고는 파이썬 스크립트를 실행하지 않는 것 같습니다.
- crontab은 루트의 crontab에서 실행됩니다.
echo "Run :$(date)" >> python_temp.log python write_temp.py >> python_temp.log python temp_to_file.py >> python_temp_to_file.log #raspistill -o snapshot2.jpg -n -w 1280 -h 720 python takePic.py sleep 3 HOST=XX #This is the FTP servers host or IP address. USER=XX #This is the FTP user that has access to the server. PASS=XX #This is the password for the FTP user. NOW=$(date +"%c") # echo beginne upload touch work ftp -inv $HOST << EOF user $USER $PASS cd /bilder/ put snapshot2.jpg rename snapshot2.jpg snapshot.jpg put temp.js bye EOF # echo erfolgreicher upload
:
- 파이썬 파일 I 스크립트가 수동으로 모든 것을 완벽하게
ftp.sh 작동 실행하면 로그 파일은 아무것도
import subprocess
import datetime
import sys
output = subprocess.check_output("temper-poll -q -c" , shell=True)
output = output.rstrip()
#write to file
fobj_out = open("temp.js","w")
fobj_out.write('document.write("' + output + '*C ");')
fobj_out.close()
crontab 명령 :
*/5 * * * * /root/ftp.sh
또한 crontab 구문을 게시하십시오. http://stackoverflow.com/tags/crontab/info를 통해 가봤습니까? 좋은 디버깅 정보가 있습니다. – fedorqui
문제는 subprocess_check_output이 crontab과 작동하지 않는다고 생각합니다. –
crontab이 실행중인 위치를 모르기 때문에 전체 경로를 사용해야 할 수도 있습니다. 내가 제공 한 링크를 확인하십시오. 좋은 정보가 있습니다. – fedorqui