buy
Cron Job

Overview

You can use this  API to Add/Edit  cron job, Delete cron and Update cron email in your Webuzo panel.

Add Cron Job

The following guide will show to how to add cron job using API

Parameters

Sample code

curl --insecure -d "create_record=1"  -d "minute=*" -d "hour=*" -d "day=*" -d "month=*" -d "weekday=*" -d "cmd=command" -u "username:password" -X POST "https://Server Ip or Hostname:2003/index.php?api=json&act=cronjob"
<?php
	$user = 'username';
	$pass = 'password';
	$host = 'Server Ip or Hostname';
	 
	$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2003/index.php?api=json&act=cronjob'; 

	$post = array('create_record' => '1',
		       'minute' => '*/1',
		       'hour' => '*',
		       'day' => '*',
		       'month' => '*',
		       'weekday' => '*',
		       'cmd' => 'command',
	);

	// Set the curl parameters 
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

	if(!empty($post)){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
	}

	// Get response from the server. 
	$resp = curl_exec($ch);
	if(!empty(curl_error($ch))){
		echo curl_error($ch); die();
	}

	// The response will hold a string as per the API response method. 
	$res = json_decode($resp, true);
	// Done ?
	if(!empty($res['done'])){
		echo "<pre>";
		print_r($res['done']['msg']);
		echo "</pre>";
	}else{
		print_r($res['error']);
	}
?>

Output

Cron Job added successfully

Edit Cron Job

The following guide will show to how to Add Cron job using API

Parameters

Sample Code

curl --insecure -d "edit_record=cron index id"  -d "minute=*" -d "hour=*" -d "day=*" -d "month=*" -d "weekday=*" -d "cmd=command" -u "username:password" -X POST "https://Server Ip or Hostname:2003/index.php?api=json&act=cronjob"
<?php
	$user = 'username';
	$pass = 'password';
	$host = 'Server Ip or Hostname';
	 
	$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2003/index.php?api=json&act=cronjob'; 

	$post = array('edit_record' => 'cron index number',
		       'minute' => '*/1',
		       'hour' => '*',
		       'day' => '*',
		       'month' => '*',
		       'weekday' => '*',
		       'cmd' => 'command',
	);

	// Set the curl parameters 
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

	if(!empty($post)){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
	}

	// Get response from the server. 
	$resp = curl_exec($ch);
	if(!empty(curl_error($ch))){
		echo curl_error($ch); die();
	}

	// The response will hold a string as per the API response method. 
	$res = json_decode($resp, true);
	// Done ?
	if(!empty($res['done'])){
		echo "<pre>";
		print_r($res['done']['msg']);
		echo "</pre>";
	}else{
		print_r($res['error']);
	}
?>

Output

Cron Job updated successfully.

Delete Cron

The following guide will show to how to Delete Cron job using API

Parameters

Sample Code

curl --insecure -d "delete_record=cron index id"   -u "username:password" -X POST "https://Server Ip or Hostname:2003/index.php?api=json&act=cronjob"
<?php
	$user = 'username';
	$pass = 'password';
	$host = 'Server Ip or Hostname';
	 
	$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2003/index.php?api=json&act=cronjob'; 

	$post = array('delete_record' => 'cron index number',
        );

	// Set the curl parameters 
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

	if(!empty($post)){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
	}

	// Get response from the server. 
	$resp = curl_exec($ch);
	if(!empty(curl_error($ch))){
		echo curl_error($ch); die();
	}

	// The response will hold a string as per the API response method. 
	$res = json_decode($resp, true);
	// Done ?
	if(!empty($res['done'])){
		echo "<pre>";
		print_r($res['done']['msg']);
		echo "</pre>";
	}else{
		print_r($res['error']);
	}
?>

Output

Cron Job deleted successfully

Update Cron Email

The following guide will show to how to Update Cron Email using API

Parameters

If you don't want to receive cron updates, leave the email field empty.

Sample Code

curl --insecure -d "update_cron_email=1" -d "email=a@a.com"   -u "username:password" -X POST "https://Server Ip or Hostname:2003/index.php?api=json&act=cronjob"
<?php
	$user = 'username';
	$pass = 'password';
	$host = 'Server Ip or Hostname';
	 
	$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2003/index.php?api=json&act=cronjob'; 

	$post = array('update_cron_email' => '1',
                      'email' => 'cron email',
        );

	// Set the curl parameters 
	$ch = curl_init(); 
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

	if(!empty($post)){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
	}

	// Get response from the server. 
	$resp = curl_exec($ch);
	if(!empty(curl_error($ch))){
		echo curl_error($ch); die();
	}

	// The response will hold a string as per the API response method. 
	$res = json_decode($resp, true);
	// Done ?
	if(!empty($res['done'])){
		echo "<pre>";
		print_r($res['done']['msg']);
		echo "</pre>";
	}else{
		print_r($res['error']);
	}
?>

Output

Cron Email updated successfully.

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list