Talk:Administration via command line
Note: You are currently viewing documentation for Moodle 2.3. Up-to-date documentation for the latest stable version is available here: Administration via command line.
Did a fresh install of 2.2, but I don't have the folder cd /var/www/sites/moodle/htdocs/
It's just missing, do you know where I can get it?
$ cd /var/www/sites/moodle/htdocs/ $ git fetch $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --enable $ git merge origin/cvshead $ sudo -u apache /usr/bin/php admin/cli/upgrade.php $ sudo -u apache /usr/bin/php admin/cli/maintenance.php --disable
CLI on some hosts
Keep in mind that on some hosts the user may not have the ability to use sudo. I was still able to use the cli options; however, I needed to modify the php.ini to accept arguments from the command line. The php.ini file indicates that it is best to leave the register_argc_argv setting off:
"When this directive is enabled, registering these variables consumes CPU cycles and memory each time a script is executed. For performance reasons, this feature should be disabled on production servers."
In order to avoid leaving register_argc_argv on, I copied the php.ini file. In my case I was using HostMonster.com which allows me to use a single php.ini in my home www directory (~/www/php.ini). I created a duplicate with
$ cp ~/www/php.ini ~/www/php-cli.ini
Then I edited the ~/www/php-cli.ini file and changed it so that:
register_argc_argv = On
In my upgrademoodle script then I used the following:
$ php -c ~/www/php-cli.ini admin/cli/maintenance.php --enable $ php -c ~/www/php-cli.ini admin/cli/upgrade.php --non-interactive $ php -c ~/www/php-cli.ini admin/cli/maintenance.php --disable
I did not have to use sudo (and could not use it because I am not a sudoer on the host). I used the php-cli.ini file so that it will accept the command line arguments without creating a potentially increased performance load on the server. Initially, I was getting a segmentation fault because the server was not picking up that I wanted to run a non-interactive upgrade and it would not allow me to provide the input either and simply cycled through requesting the confirmation to upgrade. I eventually was able to get things working the way I wanted so hopefully these comments might be of help to others who might be experiencing difficulty using Administration via command line on a shared host. Peace - Anthony