【问题标题】:cron.hourly "exited with return code 1"cron.hourly “退出并返回代码 1”
【发布时间】:2017-11-09 14:41:32
【问题描述】:

我目前使用的是 Linux Ubuntu 14.04(我认为)。

所以我之前有一个运行良好的 cron.daily 脚本。我决定使用相同的脚本,但将其移至 cron.hourly,现在它不起作用了。

/etc/cron.hourly/dstealth-watch-tv

#!/bin/bash

times=$(date)
echo "${times}:" >> /var/log/dstealth/watch-tv.log
/usr/bin/curl --silent http://watch.dstealth.com/tv/refreshToken.php?k=secretRefreshKey >> /var/log/dstealth/watch-tv.log

我给了文件 CHMOD: 755

日志文件是使用 CHMOD: 644 手动创建的,并且是空的。

然后我用了:

service cron reload

并等待了几个小时希望输出到我的日志文件中,但它仍然是空的。

我试过了

run-parts --verbose /etc/cron.hourly

这是我得到的输出:

/etc/cron.hourly/dstealth-watch-tv:
run-parts: failed to exec /etc/cron.hourly/dstealth-watch-tv: No such file or directory
run-parts: /etc/cron.hourly/dstealth-watch-tv exited with return code 1

这也没有导致任何内容被输入到日志文件中。我不确定我哪里出错了。请帮忙。

【问题讨论】:

标签: linux ubuntu cron scheduled-tasks


【解决方案1】:

感谢 JWW 的指导,我在 Unix & Linux Stack Exchange 上发帖,几乎立即有人回答了这个问题。

该脚本基本上是在 Windows 中使用 NppFTP 创建的,因此需要以下命令:

dos2unix /etc/cron.hourly/dstealth-watch-tv
  • 归功于 roaima

【讨论】: