Welcome Guest, Not a member yet? Register   Sign In
Add cronjob command line
#1

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

Thanks
Reply
#2

(This post was last modified: 10-31-2019, 12:24 PM by dave friend.)

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}
Reply
#3

(This post was last modified: 10-31-2019, 12:51 PM by omid_student.)

(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
Reply
#4

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.
Reply
#5

(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
Reply
#6

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

Attached Files
.php   Crontab.php (Size: 1.08 KB / Downloads: 7)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB