Execute command line and shell commands from PHP
PHP’s system() command will let you run command line and shell stuff. It probably requires proper permissions on your ISP configuration.
http://www.php.net/manual/en/function.system.php
$last_line = system(‘PATHTO_COMMAND’, $retval);
Why do I need this? For the life of me I can’t figure out how to run a simple shell script through cron.
I saw somewhere that the cron would be something like this but it does not work:
10 * * * `/bin/sh PATHTOSCRIPT`
Inspired by Drupal’s cron.php stuff that runs search indexing, I wrote a PHP script that will run my shell commands. Since the scripts can echo to standard out, the PHP command will print the debugging results to the web page. Now I can check the status of my script without logging in through SSH every time.
There is definitely a better way to do this. Let me know if you can think of something. If anyone knows how to run a shell script (/bin/sh) through cron via cPanel’s cron admin please let me know.
Recent blog posts
- Amazon S3 Website CNAME
- Button labels for checkout
- Insert html django contrib messages
- Twitter Bootstrap not working with LESS.js
- Javascript libs that offer basic subset of jquery features
- Building the donor-matic
- Playing with free Google Map alternatives.
- Some flows are not as complicated as they appear
- Form design crib sheet
- Script to get IE9 Windows Virtual PC images into Virtual Box