Pergunta

I want to get the php file below to run every day on my server. (Changing "username" to my WHMCS username) I've read that this should do it:

20 0 * * * php –q /home/username/whmcs/terminatedemo.php

but when I run it this way I get this error message: "No input file specified"

I tried running it like this based on a CPanel forum thread and got the exact same results:

20 0 * * * php –q /home/username/whmcs /home/username/whmcs/terminatedemo.php

I even tried like this:

php -q -f /home/username/public_html/whmcs /home/username/public_html/whmcs/createdemo.php

This last time I get an error

Invalid IP address xxx.xx...

Any suggestions?

Thank you! (The file is below.)

<?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);
}
?>
Foi útil?

Solução

When you say "this should do it", are you using the crontab command? That's the interface for setting up cron jobs - do "man crontab".

Briefly, the easiest way is to "crontab -e" to bring up the editor with the current cron file, so you can add further commands.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top