forked from jackyzha0/quartz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_cron.sh
More file actions
executable file
·31 lines (24 loc) · 922 Bytes
/
setup_cron.sh
File metadata and controls
executable file
·31 lines (24 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
### You can do this yourself! Edit the following to your setup and it (should)
#work for you too
# Configuration - Edit these variables to customize
SCRIPT_DIR="/home/mat/Documents/blog"
SCRIPT_NAME="daily_poem.py"
CRON_TIME="0 8 * * *" # Run at 8:00 AM daily
LOG_FILE="poem_cron.log"
# Full path to the script
SCRIPT_PATH="${SCRIPT_DIR}/${SCRIPT_NAME}"
# Verify the script exists
if [ ! -f "$SCRIPT_PATH" ]; then
echo "Error: Script not found at $SCRIPT_PATH"
exit 1
fi
# Ensure script is executable
chmod +x "$SCRIPT_PATH"
# Add cron job
(crontab -l 2>/dev/null; echo "$CRON_TIME cd $SCRIPT_DIR && ./$SCRIPT_NAME >> $LOG_FILE 2>&1") | crontab -
echo "Cron job set up to run at: $CRON_TIME"
echo "The script will run from: $SCRIPT_DIR"
echo "Logs will be written to: $SCRIPT_DIR/$LOG_FILE"
echo "To verify, run: crontab -l"
echo "The script will use the ANTHROPIC_API_KEY from your environment."