cron job and codeigniter

realopti

New Member
Messages
8
Reaction score
0
Points
0
Hi everyone,

I am trying to set up a cronjob script to run a controller in a codeignier php project. I have looked up other forum posts on cronjobs, and tried to model my syntax on these, but so far I can't get it working.

Code:
[TABLE="class: dynamic_table"]
[TR="class: dt_info_row info-odd"]
[TD][/TD]
         [TD][/TD]
         [TD][/TD]
         [TD][/TD]
         [TD][/TD]
[/TR]
[/TABLE]
*/5 **** /usr/bin/php /home/realopti/public_html/hmvcExample/index.php/welcome>./log2

Could anyone give me a hand? Thanks in advance,

Bill
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
index.php/welcome

Why the /welcome?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
That is fine if you are accessing it via the Web.

Your command is trying to find and run the file /home/realopti/public_html/hmvcExample/index.php/welcome

Do you have directory index.php with a file welcome in it?
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The command line ain't the web. When you run a script via the command line, CGI doesn't come into play, so you won't have superglobals such as $_SERVER and $_GET. If your scripts need these, either write a boot script that sets them, or use curl or wget. As for the latter two not succeeding, how do you tell? What did you expect to happen, and what actually happened (including any error messages)? You should always include this information when asking for help.
 

realopti

New Member
Messages
8
Reaction score
0
Points
0
The command line ain't the web. When you run a script via the command line, CGI doesn't come into play, so you won't have superglobals such as $_SERVER and $_GET. If your scripts need these, either write a boot script that sets them, or use curl or wget. As for the latter two not succeeding, how do you tell? What did you expect to happen, and what actually happened (including any error messages)? You should always include this information when asking for help.

Thanks for looking into this. I have the cronjobs set up to send me an email on execution, but they never did so I assume they are not working
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
I believe that the cron e-mail feature in cPanel is disabled. At least, it was at one point and I don't remember reading about it being re-enabled. It's better to handle logging yourself. The X10 Wiki article on cron jobs has examples on how to capture output in a file. You could also have the script log information itself.
 

realopti

New Member
Messages
8
Reaction score
0
Points
0
I believe that the cron e-mail feature in cPanel is disabled. At least, it was at one point and I don't remember reading about it being re-enabled. It's better to handle logging yourself. The X10 Wiki article on cron jobs has examples on how to capture output in a file. You could also have the script log information itself.

Hi ,

I read over the cron jobs wiki. Yesterday before I started posting here I was able to get the linux 'mail' command working as a cron job. So I think what you are saying is that: under the cpanel cron job setting, where it says it will send an email notification when a cron job runs, that ability is disabled. Is that correct?

What about lynx , wget or curl? I know that entering http://realoption.x10.mx/hmvcExample/index.php/welcome into the browser works, are you able to create a cronjob on your system using any of those commands on the above url?
It seems like the simplest way.

Bill



I
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Yesterday before I started posting here I was able to get the linux 'mail' command working as a cron job. So I think what you are saying is that: under the cpanel cron job setting, where it says it will send an email notification when a cron job runs, that ability is disabled. Is that correct?
Yes. The command line "mail" program is not the cPanel e-mail feature.

What about lynx , wget or curl? I know that entering http://realoption.x10.mx/hmvcExample/index.php/welcome into the browser works, are you able to create a cronjob on your system using any of those commands on the above url?
Yes. wget and curl would be the preferred programs, as they are designed for non-interactive use. As for the differences between wget and curl, they each have their own functionality not supported by the other, but (for your purposes) both should work equally well.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Code:
/usr/bin/curl -s -S  "http://realoption.x10.mx/hmvcExample/index.php/welcome" >>/home/realopti/public_html/PATH/TO/LOG/FILE  2>&1


Should work. The equivalent works on my account on Chopin.

wget does not work.

The log file catches any output from the script, also any system errors (ie, if curl is missing or throws an error itself).
 

realopti

New Member
Messages
8
Reaction score
0
Points
0
Hi Guys,

You got it working! Thank you very much . I was tearing my hair out...

Bill
 
Top