我想让下面的php文件每天都在我的服务器上运行。 (将“用户名”更改为我的WHMCS用户名)我已经读过这应该这样做:
20 0 * * * php –q /home/username/whmcs/terminatedemo.php
但是当我以这种方式运行时,我收到此错误消息:“未指定输入文件”
我尝试在CPanel论坛帖子的基础上运行它并得到完全相同的结果:
20 0 * * * php –q /home/username/whmcs /home/username/whmcs/terminatedemo.php
我甚至尝试过这样:
php -q -f /home/username/public_html/whmcs /home/username/public_html/whmcs/createdemo.php
上次我收到错误
无效的IP地址xxx.xx ...
有什么建议吗?
谢谢! (文件如下。)
<?php
//RECREATING DEMO ACCOUNT
$url = "http://yourdomain.com/whmcs/includes/api.php"; # URL to WHMCS API file
$whmcs_admin = "admin"; # Admin username goes here
$whmcs_pw = "password";
$demo_account_id = "1";
$postfields["username"] = $whmcs_admin;
$postfields["password"] = md5($whmcs_pw);
$postfields["action"] = "servercreate";
$postfields["accountid"] = "1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);
$data = explode(";",$data);
foreach ($data AS $temp) {
$temp = explode("=",$temp);
$results[$temp[0]] = $temp[1];
}
if ($results["result"]=="success") {
print "Demo account terminated";
} else {
# An error occured
$error_msg = $results["message"];
mail("youremail", "Error terminating demo account", $error_msg,$headers);
}
?>
答案 0 :(得分:0)
当你说“这应该这样做”时,你使用的是crontab命令吗?这是设置cron作业的界面 - 做“man crontab”。
简单来说,最简单的方法是“crontab -e”使用当前的cron文件调出编辑器,这样就可以添加更多命令。