PHP Automated Administrivia?
wikinerd asks: "I am sure all of you know what PHP is and many of you may even use it on your websites, like me. Some of you may have read a this article from Linux.com article that gives some examples on how to use PHP to automate your server administration tasks (or to say it with one word: administrivia). I wonder whether there are any Slashdot users that have already used PHP in their administrivia, and what the results are. Is PHP appropriate for this task? If you have written useful PHP scripts, would you consider to publish their source code here? I am sure that posting your scripts can be beneficial to many new (and old) admins, so let's share our work!"
I've never run into problems with memory leaks, but PHP is still not designed to really be a shell scripting language. The biggest issue I get is "PHP Fatal error: Unable to start session mm module in Unknown on line 0" from cron jobs. Apparently you can't start two instances of PHP at the exact same time, or you get this problem. The only fix I could find was to wrap each PHP script in a SH script as so:
/usr/local/bin/some_script.php
#!/bin/sh
RET=1; while [ $RET != 0 ]; do
RET=$?; done
very dirty, but it ensures the script is attempted to be run forever until it finally doesn't fail to start up the PHP engine. 95% of the time the scripts run fine the first time, and the rest of the time they spit out the above error once and run just fine the second time. I log all of the cron output and thats all I ever see is this PHP error now a few times a week.
Morphing Software
PHP is not a bad scripting language, though it is mostly used for web backends. I think a lot of admins are still more comfortable using something like PERL for these kinds of tasks
if you add a bit of textutils and pipe-fu into the mix it can do wonders. i use it for scheduled db backups, monitoring [ups, services, etc.]. its always proven itself very flexible and useful.
and if youre looking for some ideas you could always check out some oss projects
Stop Computers/Cars Analogies on S
In my experience, reporting bugs to PHP is a pretty pointless endeavor.
I needed ONE simple function and of course, it's broken on freebsd, and the ticket hasn't been touched since it was assigned in august... =\