cPanel xmlapi - oprette cronjob
HejJeg skal have lavet et script der opretter et cronjob på en server hvor Cpanel er installeret - jeg kan gennem xmlapi få oprettet subdomæne - det fungerer fint - men jeg kan ikke få oprettet cronjobbet - kan nogen gennemskue hvad der er galt?
Eller hvis du har en alternativ måde at oprette et cronjob på.
Serveren kører linux
DETTE FUNGERER
------------------------------
<?php
include_once("xmlapi.php");
$cPanelUser = 'cpanel_user';
//Topdomænet hvor subdomænet skal laves på
$cPanelDomain = 'domæne.dk';
//navn på subdomæne
$ipccSub = 'subdir';
// CREATE SUBDOMAIN
$xmlapi->api1_query($cPanelUser, 'SubDomain', 'addsubdomain', array($ipccSub,$cPanelDomain,0,0, $ipccDir));
?>
-----------------------
MEN DETTE FUNGERER IKKE
det her kan jeg ikke få til at fungere - jeg har funder kodestykker på denne side:
https://stackoverflow.com/questions/23544851/how-to-set-up-a-cron-job-programmatically
<?
include_once("xmlapi.php");
$ip = '198.98.54.127';
$account = 'user';
$pass = "pass";
$xmlapi = new xmlapi($ip, $account, $pass);
/*
* Just to be sure that XML-API will use the correct port and protocol
* @set_port(port); change port to 2082 if it isn't redirected to HTTPS and/or using HTTP protocol, else.. use 2083
* @set_protocol(protocol); change protocol to http if your sever accept HTTP else put the protocol to https
* @set_output(format); change to XML if you want the result output w/ XML, JSON if you want the result output w/ JSON
*/
$xmlapi->set_port('2083');
$xmlapi->set_protocol('http');
$xmlapi->set_output("json");
$xmlapi->set_debug("true");
/*
* @command string - The command, script, or program you wish for your cronjob to execute.
* @day int - The day on which you would like this crontab entry to run. Wildcards and any acceptable input to a crontab time expression line are allowed here.
* @hour int - The hour at which you would like this crontab entry to run. Wildcards and any acceptable input to a crontab time expression line are allowed here.
* @minute int - The minute at which you would like this crontab entry to run. Wildcards and any acceptable input to a crontab time expression line are allowed here.
* @month int - The month you would like this crontab entry to run. Wildcards and any acceptable input to a crontab time expression line are allowed here.
* @weekday int - The weekday on which you would like this crontab entry to run. Wildcards and any acceptable input to a crontab time expression line is allowed here. Acceptable values range from 0 to 6, where 0 represents Sunday and 6 represents Saturday.
*/
$command = "/usr/local/bin/php /home/i/test.php";
$day = "1";
$hour = "1";
$minute = "1";
$month = "1";
$weekday = "1";
/*
* @api2_query(account, module, function, params)
*/
print $xmlapi->api1_query($account, "Cron", "add_line", array(
"command"=>$command,
"day"=>$day,
"hour"=>$hour,
"minute"=>$minute,
"month"=>$month,
"weekday"=>$weekday
));