i have a function that need run every day at 00:00 AM,
i do some research but not any result coming up with my cron job.
this is my function code :
public function aro()
{
$this->deposito_m->exec_aro();
echo 'oke';
}
my deposito_m is:
function exec_aro()
{
$tgl_now = date('Y-m-d');
$data = $this->get_data_deposito_aro($tgl_now);
if (!empty($data)) {
foreach ($data as $x) {
$transaksi = $x->tgl_transaksi;
$tgl_awal = substr($transaksi, 0, 10);
$jenis_ang = $x->jenis_ang;
$tanggal_berakhir = date('Y-m-d', strtotime("+" . $jenis_ang . " months", strtotime($tgl_awal)));
$anggota_id = $x->anggota_id;
$akun = $x->akun;
$dk = $x->DK;
// $tanggal_berakhir = $x->tgl_berakhir;
$kas_id = $x->kas_id;
$user_name = $x->user_name;
$nama_penyetor = $x->nama_penyetor;
$no_identitas = $x->no_identitas;
$alamat = $x->alamat;
$jumlah_awal = $x->jumlah;
$conf_bunga = $this->bunga_m->get_key_val();
$bunga_deposit = $conf_bunga['suku_bunga_deposit'];
$pajak = $conf_bunga['pajak_depo'];
$bunga = $jumlah_awal * ($bunga_deposit / 100) * ($x->jenis_ang / 12);
$total_bunga = $bunga - ($bunga * ($pajak / 100));
$jumlah = $jumlah_awal + $total_bunga;
$create_arr = array(
'tgl_transaksi' => $tgl_now,
'anggota_id' => $anggota_id,
'jenis_ang' => $jenis_ang,
'jumlah' => $jumlah,
'keterangan' => 'new',
'akun' => $akun,
'DK' => $dk,
'kas_id' => $kas_id,
'tgl_berakhir' => $tanggal_berakhir,
'update_data' => $tgl_now,
'user_name' => $user_name,
'no_identitas' => $no_identitas,
'alamat' => $alamat,
'nama_penyetor' => $nama_penyetor,
'status' => 'on_progress',
);
$this->db->insert('tbl_trans_dep', $create_arr);
}
} else {
return 'tidak ada data';
}
}
and my controller is :
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Deposito_status extends OperatorController
{
public function __construct()
{
parent::__construct();
$this->load->helper('fungsi');
$this->load->model('deposito_m');
$this->load->model('general_m');
}
public function index()
{
$this->data['judul_browser'] = 'Data Deposito';
$this->data['judul_utama'] = 'Deposito';
$this->data['judul_sub'] = 'Status Deposito';
//table
$this->data['css_files'][] = base_url() . 'assets/extra/bootstrap-table/bootstrap-table.min.css';
$this->data['js_files2'][] = base_url() . 'assets/extra/bootstrap-table/bootstrap-table.min.js';
$this->data['js_files2'][] = base_url() . 'assets/extra/bootstrap-table/extensions/filter-control/bootstrap-table-filter-control.min.js';
$this->data['js_files2'][] = base_url() . 'assets/extra/bootstrap-table/bootstrap-table-id-ID.js';
//modal
$this->data['css_files'][] = base_url() . 'assets/extra/bootstrap-modal/css/bootstrap-modal-bs3patch.css';
$this->data['css_files'][] = base_url() . 'assets/extra/bootstrap-modal/css/bootstrap-modal.css';
$this->data['js_files'][] = base_url() . 'assets/extra/bootstrap-modal/js/bootstrap-modalmanager.js';
$this->data['js_files'][] = base_url() . 'assets/extra/bootstrap-modal/js/bootstrap-modal.js';
$this->data['js_files'][] = base_url() . 'assets/extra/bootstrap-modal/js/nsi_modal_default.js';
// datepicker
$this->data['css_files'][] = base_url() . 'assets/theme_admin/css/datepicker/datepicker3.css';
$this->data['js_files'][] = base_url() . 'assets/theme_admin/js/plugins/datepicker/bootstrap-datepicker.js';
$this->data['js_files'][] = base_url() . 'assets/theme_admin/js/plugins/datepicker/locales/bootstrap-datepicker.id.js';
//$this->data['barang_id'] = $this->pinjaman_m->get_id_barang();
//daterange
$this->data['css_files'][] = base_url() . 'assets/theme_admin/css/daterangepicker/daterangepicker-bs3.css';
$this->data['js_files'][] = base_url() . 'assets/theme_admin/js/plugins/daterangepicker/daterangepicker.js';
//select2
$this->data['css_files'][] = base_url() . 'assets/extra/select2/select2.css';
$this->data['js_files'][] = base_url() . 'assets/extra/select2/select2.min.js';
//editable
$this->data['css_files'][] = base_url() . 'assets/extra/bootstrap3-editable/css/bootstrap-editable.css';
$this->data['js_files'][] = base_url() . 'assets/extra/bootstrap3-editable/js/bootstrap-editable.min.js';
$this->data['jenis_ags'] = $this->deposito_m->get_data_angsuran();
$this->data['isi'] = $this->load->view('deposito_status_v', $this->data, TRUE);
$this->load->view('themes/layout_utama_v', $this->data);
}
public function ajax_deposito()
{
// $this->load->model('deposito_m');
$out = $this->deposito_m->get_deposito();
header('Content-Type: application/json');
echo json_encode($out);
exit();
}
function aksi()
{
$this->load->model('deposito_m');
if ($this->deposito_m->deposito_aksi()) {
echo 'OK';
} else {
echo 'Gagal';
}
}
// function get_jenis_simpanan()
// {
// $id = $this->input->post('jenis_id');
// $jenis_simpanan = $this->general_m->get_id_simpanan();
// foreach ($jenis_simpanan as $row) {
// if ($row->id == $id) {
// echo number_format($row->jumlah);
// }
// }
// exit();
// }
function get_jenis_angsuran()
{
$id = $this->input->post('jenis_ang_grid');
$jenis_angsuran = $this->general_m->get_jns_angsuran();
foreach ($jenis_angsuran as $row) {
if ($row->ket == $id) {
echo number_format($row->jumlah);
}
}
exit();
}
public function aro()
{
$this->deposito_m->exec_aro();
echo 'oke';
}
}
my crontab -l in server is :
0 0 * * * /usr/bin/php /home/admin/web/kspspmi.dieselone.co.id/public_html/index.php deposito_status/aro
i try with * * * * * to know my cron is running or not, in log there is some CMD running but nothing happens with my data in database.
Can someone help me what is wrong or how to do cron job in server,
Thank you.