Page 1 of 1

Detecting CLI/CRON support

Posted: Mon Nov 12, 2007 5:58 pm
by alex.barylski
Using strictly PHP is there a reliable method for detecting/updating cron? I want to show a message indicating whether it's enabled or not as my application needs cron functionality.

Also, if cron is not available (shared hosts, etc) I would like to check for the possibility of using CLI to carry out the actions instead. Is there a php.ini setting which I can check that will tell me where and whether or not CLI is possible?

Cheers :)

Posted: Mon Nov 12, 2007 8:33 pm
by feyd
You can run the "which" command via system() to find commands (if you're on a *nix based system.)

Posted: Tue Nov 13, 2007 12:56 am
by alex.barylski
I imagine it'll be running mostly on Linux systems...

Although I am not sure I see how I could use this command for my use???

For detecting CLI support? So I would do something like:

Code: Select all

which php5-cli
Which would return the fullpath?

Couldn't i just rely on the error message returned when invoking a command that doesn't exist?

Posted: Tue Nov 13, 2007 1:41 am
by feyd
Hockey wrote:Couldn't i just rely on the error message returned when invoking a command that doesn't exist?
Then why did you make this topic in the first place?

There is no way to detect its existence without testing for it or trying to run it. Either way will return some result. Which one are you satisfied with?