cron作业不会写入文件 [英] cron job won't write to file
本文介绍了cron作业不会写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我运行一个windows 2003服务器,并试图每15分钟运行一次这样的代码:
I run a windows 2003 server and tried to run a code like this every 15 minutes:
require("db_connect.php");
$conn = db_connect();
//list online brukere - flytt funksjon til separat side for bedre ytelse
$time = time() - 900;
$query ="SELECT username FROM tbl_user WHERE last_online >= $time";
$online_users;
if ($result = $conn->query($query)) {
while ($row = $result->fetch_assoc()) {
$online_users .= $row["username"].":";
}
$result->close();
}
$filename = "online_users.txt";
$fp = fopen($filename,"w");
fputs($fp,$online_users);
fclose($fp);
当我转到url或从命令行运行它工作和写入文件。但是任务只是运行,不保存文件..出了什么问题?
When I go to the url or run it from the command line it works and write to file. But the task just run and don't save the file.. What's wrong?
推荐答案
$filename = dirname(__FILE__) . "/online_users.txt";
这篇关于cron作业不会写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文