我有一个bash脚本来自动化我做的一些事情。bash调用2个python脚本,如果我正常运行bash脚本,一切都会运行,没有任何错误。我设置了一个cron作业来实现自动化,当我检查日志时,我注意到python脚本根本不运行。它给了我以下错误。
python: can't open file 'movefiles.py': [Errno 2] No such file or directory
python: can't open file 'create_log_shimmer.py': [Errno 2] No such file or dir
我正在运行一个带有连接摄像头的Raspberry pi,并希望使用crontab自动上传每小时一次的照片。
图片由另一个shell脚本每6分钟拍摄一次,这也是由crontab控制,工作良好。
上传文件的python脚本在从shell调用文件时按预期工作。它构建正确的文件名并上传它们。下面是脚本:
#!/usr/bin/env python
import dropbox
import os.path
import time
#pictures are taken every 6 minutes so this is used to build the file names:
interval
我试图在Ubuntu中自动化bash脚本。脚本调用服务器,如果未收到数据包,则运行python脚本。python脚本在ping未返回时向我发送通知。当我手动运行脚本时,它会工作,但是当我安排cron作业时,它就不能工作了。
bash脚本名为ping.sh。
#!/bin/bash
pingString=$(ping -c 1 google.com) # google is just and example, for my script I am using a server that intentionally does not return the packet.
msgRecieve
我通过python crontab模块从另一个python脚本运行python脚本,它没有返回任何东西,作业也没有执行。
caller.py
from crontab import CronTab
import os
cron = CronTab()
job = cron.new(command='job1.py')
job.minute.during(1,5).every(1)
job.enable()
if job.is_valid():
print True
job1.py
for i in range(0,2,1):
f=ope