Cron作业错误“无法打开输入文件” [英] Cron Job error "Could not open input file"
问题描述
我已经花了一天的时间寻找解决这个特定的情况(在Stack Overflow和Googs,所以我道歉,如果这已经在Stack Overflow)。
I've spent a solid day looking for a solution to this specific situation (on Stack Overflow and the Googs,) so I do apologize if this is already on Stack Overflow.
我试图通过命令行在AWS中设置一个相当简单的cron作业:
I'm trying to set up a fairly simple cron job in AWS via the command line:
* * * * * /usr/bin/php /opt/app/current/record_user_login.php
成功触发并能够触摸有问题的文件(它正在击中正确的环境。)但是,我一直收到错误:
The cron job successfully fires and is able to touch the file in question (it is hitting the correct environment.) However, I keep getting the error:
"Could not open input file"
我有:
- 将文件拖到777
- 将脚本更改为只回显Hello world
- 尝试以root用户身份启动cronjob
- 将crontab文件自身更改为777
- chmod'd the file to 777
- Changed the script to just echo "Hello world"
- Tried initiating the cronjob as the root user
- chmod'd the crontab file itself to 777
这些解决方案似乎都无效。因为一个未知的原因,我不能编辑rsyslog.conf打开cronlog,所以我没有任何数据。
None of these solutions seem to work. For a yet unknown reason, I can't edit rsyslog.conf to turn on cronlog, so I don't have any data from that.
record_user_login的内容是:
The contents of record_user_login are:
<?
include("connect_to_mysql.php");
//Logged in in 1 week
$current_date = date('Y-m-j H:i:s', strtotime("-1 weeks"));
$query = "SELECT DISTINCT user_id FROM users_login_history WHERE sign_in_time > '$current_date'";
$result = mysql_query($query) or die(mysql_error());
$i = 0;
while($row = mysql_fetch_array($result)){
$i++;
}
$query = "INSERT INTO sqm_data (feature, action) VALUES ('user login', $i)";
if(!mysql_query($query)) {
die('Error: ' . mysql_error());
}
?>
任何想法?
推荐答案
这是荒谬的晚了游戏,但我找到了一个解决方案。发生了什么:
This is absurdly late to the game, but I did find a solution to this. What was happening was:
我最初在Windows记事本中输入了cron命令并上传了它们。显然发生了什么是一个回车(/ r,IIRC)被插入,不知道我(和vim,当我看到从putty的文件)。一个朋友删除那些回车的方法我不回忆/不太好,不幸的是,但在回报被删除后,一切工作。
I had originally typed up the cron commands in Windows Notepad and uploaded them. Apparently what was happening was a carriage return ("/r", IIRC) was getting plugged in, unbeknownst to me (and vim, when I viewed the file from putty.) A friend removed those carriage returns by a method I don't recall/did not follow too well unfortunately, but after the returns were removed, it all worked.
这篇关于Cron作业错误“无法打开输入文件”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!