Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions cron/SETUP-INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Cluster Shutdown Cron Job Setup

## Installation

1. **Copy the script to your home directory:**
```bash
cp ./shutdown-cluster.sh ~/bin/shutdown-cluster.sh
chmod +x ~/bin/shutdown-cluster.sh
```

2. **Add to crontab:**
```bash
crontab -e
```

3. **Add this line to run at 6pm daily:**
```
0 18 * * * $HOME/bin/shutdown-cluster.sh
```

Or if you want it to run Monday-Friday only:
```
0 18 * * 1-5 $HOME/bin/shutdown-cluster.sh
```

## Cron Schedule Format
```
* * * * *
│ │ │ │ │
│ │ │ │ └─── Day of week (0-7, where 0 and 7 are Sunday)
│ │ │ └───── Month (1-12)
│ │ └─────── Day of month (1-31)
│ └───────── Hour (0-23)
└─────────── Minute (0-59)
```

## Check Logs

Logs are written to: `~/.logs/shutdown-cluster.log`

```bash
tail -f ~/.logs/shutdown-cluster.log
```

## Verify Cron Job

List your cron jobs:
```bash
crontab -l
```

## Test Manually

You can test the script manually:
```bash
~/bin/shutdown-cluster.sh
```
31 changes: 31 additions & 0 deletions cron/shutdown-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Shutdown cluster at 6pm daily
# This script changes to the deploy directory, runs make shutdown-cluster stop, then returns

set -e

LOG_FILE="$HOME/.logs/shutdown-cluster.log"
mkdir -p "$(dirname "$LOG_FILE")"

echo "=== $(date '+%Y-%m-%d %H:%M:%S') - Starting cluster shutdown ===" >> "$LOG_FILE"

# Save current directory
ORIGINAL_DIR=$(pwd)

# Change to deploy directory
cd "$HOME/Projects/jaypoulz/two-node-toolbox/deploy" || {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need $USER here? Or maybe we set this path as part of the setup instructions commands?

echo "ERROR: Failed to change to deploy directory" >> "$LOG_FILE"
exit 1
}

# Run make command
if make shutdown-cluster stop >> "$LOG_FILE" 2>&1; then
echo "SUCCESS: Cluster shutdown completed" >> "$LOG_FILE"
else
echo "ERROR: make shutdown-cluster stop failed with exit code $?" >> "$LOG_FILE"
fi

# Return to original directory
cd "$ORIGINAL_DIR" || true

echo "=== Shutdown complete ===" >> "$LOG_FILE"