简体   繁体   English

sh脚本未与Crontab一起运行,而是手动运行

[英]sh script not running with Crontab, but runs manually

Hi I have to jobs scheduled in crontab. 嗨,我必须在crontab中安排工作。 I didn't create any dependency between those jobs. 我没有在这些工作之间创建任何依赖关系。 both sh scripts work manually but only the first sh works with cron tab. 这两个sh脚本都是手动工作的,但是只有第一个sh可以与cron选项卡一起工作。

46 08 * * * /Users/joaopimenta/Documents/joaopython/scripts/runScript.sh 48 08 * * * /Users/joaopimenta/Documents/joaopython/scripts/automatecsv.sh 46 08 * * * /Users/joaopimenta/Documents/joaopython/scripts/runScript.sh 48 08 * * * /Users/joaopimenta/Documents/joaopython/scripts/automatecsv.sh

Not the second one -> sh script for the second: 第二个不是第二个-> sh脚本:

 cd /Users/joaopimenta/Documents/joaopython source env/bin/activate python ./ProdSqlToCsvHeaders.py 

I wonder if it's because the second sh, is actually pulling a python script which generates a csv file always with the same name but with new data everyday. 我想知道是否是因为第二个sh实际上是拉一个python脚本,该脚本始终以相同的名称生成csv文件,但每天都有新数据。 So the script just keeps replacing a csv file with the same name but new data. 因此,脚本只会继续用相同的名称替换csv文件,但添加新数据。

在这种情况下,最好的方法是直接执行脚本

/yourenv/bin/python yourscript.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM