Is there a way to find out if Cron Jobs are available on the server? I mean I want to detect this in a PHP script..
It doesn't show anything..
Adrian M.
2010-05-01 15:58:35
@Adrian it can give you an idea. Stackoverflow can show you the way, but it can't solve your problems like magic wand.
Col. Shrapnel
2010-05-01 16:42:15
@Col. is that a PHP line of code?
zaf
2010-05-01 17:21:31
@zaf it is php line of code that executes external program
Col. Shrapnel
2010-05-01 17:35:35
@Col. I didn't down vote but that does not work for me. You sure you don't mean a BASH line of code or something similar? I've never seen something like that in PHP...
zaf
2010-05-02 08:32:11
works for me :)
Phill Pafford
2010-05-03 15:01:42
@zaf google for the "PHP backtick operator"
Col. Shrapnel
2010-05-03 16:12:17
@Col. you got me! Your example returns blank for all system commands. Is it because the feature is disabled by default?
zaf
2010-05-03 16:15:48
A:
You would have to use system()
to determine that reliably:
system('crontab --version', $return);
if ($return == 0)
echo 'The shell command crontab is available';
soulmerge
2010-05-01 15:41:52
@Adrian M.: You sure know those relatives that call you to tell that their computer doesn't work. And you know the first thing *you* ask them: *What* doesn't work? Is it generating an error? Is `$return` always 0? Always another value? Is there no crontab installed?
soulmerge
2010-05-01 16:11:37
It's not about PHP, it's about asking questions, giving feedback and reporting problems.
soulmerge
2010-05-01 21:05:45
A:
Just remember it's all about permissions on a Linux system, so if the user you're using doesn't have permission to read the file you should get a "File/directory doesn't exists or not found" error.
So my guess is unless you're running this as root or give permission to the user that needs to read cron, you will run into problems.
You could just look for cron files in the cron directory
On a Cent OS 5 server the cron directory id here:
/etc/cron.d/
you can have multiple crons in the directory as well.
You could parse/read the file to see what scripts are configured in cron as well.
Phill Pafford
2010-05-03 14:53:39