Skip to content

Instantly share code, notes, and snippets.

@trinhpham
Created September 5, 2023 10:49
Show Gist options
  • Save trinhpham/963dd77c7612560d5516c94ebc997caf to your computer and use it in GitHub Desktop.
Save trinhpham/963dd77c7612560d5516c94ebc997caf to your computer and use it in GitHub Desktop.
moodle upgrade
#!/bin/bash
# 0. Turn on mainternance mode then SSH to server
# 1. Switch to account `prod_onlinetraining`, using onlinetraining password
sudo su prod_onlinetraining
# 2. Move to moodle folder
cd ~/public_html/
# 2.2. Turn off cron job then wait for all cronjob finish
crontab -e
## => Then add `#` to the last line for disabling new cron job being queued
## => save file (Ctrl + X => Y => Enter)
## Wait until all cron processes finish (below command should output nothing)
ps aux | grep [c]ron.php
# 3. Update source code on current branch
git pull
# 4 (Optional) Check and move to newer branch
git branch -a
## if the hightlight branch is not the latest (current is `MOODLE_402_STABLE`)
## checkout your wanted branch
git checkout --track origin/MOODLE_402_STABLE
# 5. Run upgrade command
php8.0 admin/cli/upgrade.php
# 6. Verify the site on web, and test cron job can be run without error
php8.0 admin/cli/cron.php
# 7. Restore cronjob
crontab -e
## Then remove the `#` you added in step 2.2
## save file (Ctrl + X => Y => Enter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment