CodeIgniter Forums
Add cronjob command line - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Add cronjob command line (/showthread.php?tid=74740)



Add cronjob command line - omid_student - 10-31-2019

Hi
Can i add cronjob with php?
example shell_exec("crontab * * * * a.php");

Thanks


RE: Add cronjob command line - dave friend - 10-31-2019

I use a bash script which, on many Linux servers are located at /etc/cron.d/

Code:
#!/bin/sh

cd {CodeIgniter public root folder}
php index.php {controller} {method}

The stuff between the curly brackets needs to be supplied by you. Basically you change directory to where the CI index.php is and then run PHP using the command shown. Substitute the actual controller's and the method's names.

The command in the cron job will be something along these lines

Code:
/etc/cron.d/{name of bash script}



RE: Add cronjob command line - omid_student - 10-31-2019

(10-31-2019, 12:22 PM)dave friend Wrote: I use a bash script which, on many Linux servers are located at /etc/cron.d/

Code:
#!/bin/sh

cd {CodeIgniter public root folder}
php index.php {controller} {method}

The stuff between the curly brackets needs to be supplied by you. Basically you change directory to where the CI index.php is and then run PHP using the command shown. Substitute the actual controller's and the method's names.

The command in the cron job will be something along these lines

Code:
/etc/cron.d/{name of bash script}

Thank you
Can i use this in Shared Host(Linux)?

(10-31-2019, 12:22 PM)dave friend Wrote: I use a bash script which, on many Linux servers are located at /etc/cron.d/

Code:
#!/bin/sh

cd {CodeIgniter public root folder}
php index.php {controller} {method}

The stuff between the curly brackets needs to be supplied by you. Basically you change directory to where the CI index.php is and then run PHP using the command shown. Substitute the actual controller's and the method's names.

The command in the cron job will be something along these lines

Code:
/etc/cron.d/{name of bash script}
I have access to crontab command but cannot create new job


RE: Add cronjob command line - dave friend - 10-31-2019

If you cannot create a new job then they have locked you out. Not unreasonable because great mischief is possible.

Does the ISP provide a C-Panel where you can schedule jobs? That's pretty typical for shared hosting. They do often limit what you can accomplish though.


RE: Add cronjob command line - omid_student - 11-01-2019

(10-31-2019, 04:43 PM)dave friend Wrote: If you cannot create a new job then they have locked you out. Not unreasonable because great mischief is possible.

Does the ISP provide a C-Panel where you can schedule jobs? That's pretty typical for shared hosting. They do often limit what you can accomplish though.
No provide
I think if i use the online Cronjob services,my problem will be solved
Thanks


RE: Add cronjob command line - omid_student - 11-14-2019

Hi guys
This library is for mange cronjob
Please download and use it and if it's possible,develop it