-
Notifications
You must be signed in to change notification settings - Fork 35
Create script to help developers avoid exceeding disk quota on LC #1613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chapman39
wants to merge
4
commits into
task/chapman39/update-blt
Choose a base branch
from
task/chapman39/setup-jacamar-ci-script
base: task/chapman39/update-blt
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7b6713a
Create script to help developers avoid exceeding disk quota on LC
chapman39 675de88
check if crontab has already been installed on hostname
chapman39 2811743
only remove contents that are older then 48 hours
chapman39 c811c95
Apply suggestion from @chapman39
chapman39 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/bin/bash | ||
| # Redirect Jacamar CI from your HOME directory to your LC workspace and periodically cleanup CI jobs to avoid exceeding | ||
| # disk quota | ||
| # | ||
| # Some things to note: | ||
| # - Running this script on oslic is recommended, because its best suited for file IO | ||
| # - It's important to understand that Cron jobs are installed per node (not per machine!), so do not run this script | ||
| # more than once unless you know what you're doing. | ||
| # - For more info on Cron, see https://myconfluence.llnl.gov/spaces/RAM/pages/417729120/Cron+-+how+it+can+be+useful+for+triggering+work+at+a+given+time | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| USER_NAME="$(whoami)" | ||
| HOST_NAME="$(hostname)" | ||
| WORKSPACE_CI_DIR="/usr/workspace/${USER_NAME}/.jacamar-ci" | ||
| HOME_CI_LINK="${HOME}/.jacamar-ci" | ||
| CRON_DIR="${HOME}/crontabs" | ||
| CRON_SCRIPT_PATH="${CRON_DIR}/${HOST_NAME}Cron" | ||
|
|
||
| echo "Starting setup for user: ${USER_NAME}" | ||
| echo "Host: ${HOST_NAME}" | ||
|
|
||
| # Error checking. Guard against running this script more than once. | ||
| if [ -e "${WORKSPACE_CI_DIR}" ]; then | ||
| echo "Workspace CI directory already exists at: ${WORKSPACE_CI_DIR}" | ||
| exit 1 | ||
| fi | ||
| if [ -n "$(crontab -l 2>/dev/null)" ] ; then | ||
| echo "A cron job has already installed on ${HOSTNAME}." | ||
| exit 1 | ||
| fi | ||
| if [ -e "${CRON_DIR}" ]; then | ||
| echo "Cron directory already exists at: ${CRON_DIR}." | ||
| echo "If you want to regenerate your Cron job, first log into the specific node that has the job, then delete" | ||
| echo "it with 'crontab -r'. After that you can safely remove the crontab directory in your HOME directory." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Setup symlink | ||
| echo "Creating symlink: ${HOME_CI_LINK} -> ${WORKSPACE_CI_DIR}" | ||
| rm -rf "${HOME_CI_LINK}" | ||
| mkdir "${WORKSPACE_CI_DIR}" | ||
| ln -s "${WORKSPACE_CI_DIR}" "${HOME_CI_LINK}" | ||
|
|
||
| # Setup Cron job | ||
| cron_script_contents() { | ||
| cat <<EOF | ||
| # This cron job has been installed on $HOST_NAME. | ||
|
|
||
| # For more information about using Cron on LC: | ||
| # https://myconfluence.llnl.gov/spaces/RAM/pages/417729120/Cron+-+how+it+can+be+useful+for+triggering+work+at+a+given+time | ||
|
|
||
| # Allows you to update your Cron job without having to go to the specific node | ||
| 0,20,40 * * * * crontab ${CRON_SCRIPT_PATH} | ||
|
|
||
| # Remove contents of Jacamar CI that are older than 48 hours | ||
| 0 0 * * * srun -N1 find "${WORKSPACE_CI_DIR}" -mindepth 1 -maxdepth 1 -mtime +1 -exec rm -rf -- {} + | ||
| EOF | ||
| } | ||
|
|
||
| echo "Writing Cron file to: ${CRON_SCRIPT_PATH}" | ||
| mkdir -p "${CRON_DIR}" | ||
| cron_script_contents > "${CRON_SCRIPT_PATH}" | ||
| crontab "${CRON_SCRIPT_PATH}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.