-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-cron.sh
More file actions
executable file
·36 lines (30 loc) · 884 Bytes
/
Copy pathinstall-cron.sh
File metadata and controls
executable file
·36 lines (30 loc) · 884 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
32
33
34
35
36
#!/bin/sh
# install-cron.sh - Install cron job for synchronization
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
LOG_FILE="${SCRIPT_DIR}/sync.log"
SCRIPT="${SCRIPT_DIR}/sync.sh"
# Check if script exists
if [ ! -f "$SCRIPT" ]; then
echo "Error: sync.sh not found in $SCRIPT_DIR"
exit 1
fi
# Create cron entry (normal sync, respects frequency)
CRON_ENTRY="* * * * * cd '$SCRIPT_DIR' && '$SCRIPT' >> '$LOG_FILE' 2>&1"
# Check if already installed
if crontab -l 2>/dev/null | grep -F "$SCRIPT" >/dev/null; then
echo "Cron job already installed"
exit 0
fi
# Add to crontab
(
crontab -l 2>/dev/null
echo "$CRON_ENTRY"
) | crontab -
if [ $? -eq 0 ]; then
echo "Cron job installed successfully"
echo "Note: Sync will respect frequency settings in sync.conf"
echo "Use './sync.sh --force' to sync all tasks immediately"
else
echo "Failed to install cron job"
exit 1
fi