-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_netlogging.sh
More file actions
38 lines (31 loc) 路 1.09 KB
/
Copy pathstart_netlogging.sh
File metadata and controls
38 lines (31 loc) 路 1.09 KB
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
37
38
#!/bin/bash
# Wrapper script for Network Logging
# Generic paths - adjust SCRIPT_DIR to your installation
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PYTHON_SCRIPT="$SCRIPT_DIR/netLogging.py"
LOG_FILE="$SCRIPT_DIR/logs/cron.log"
# Create log directory if it doesn't exist
mkdir -p "$(dirname "$LOG_FILE")"
# Change to script directory
cd "$SCRIPT_DIR" || {
echo "$(date): ERROR: Could not change to $SCRIPT_DIR" >> "$LOG_FILE"
exit 1
}
# Check if virtual environment exists
VENV_PATH="$SCRIPT_DIR/venv"
if [ ! -f "$VENV_PATH/bin/activate" ]; then
echo "$(date): WARNING: Virtual environment not found. Using system Python." >> "$LOG_FILE"
PYTHON_CMD="python3"
else
# Activate virtual environment
source "$VENV_PATH/bin/activate"
PYTHON_CMD="python3"
fi
# Start network logging script
echo "$(date): Starting network logging..." >> "$LOG_FILE"
$PYTHON_CMD "$PYTHON_SCRIPT" >> "$LOG_FILE" 2>&1
EXIT_CODE=$?
echo "$(date): Network logging finished with exit code $EXIT_CODE" >> "$LOG_FILE"
exit $EXIT_CODE
exit $EXIT_CODE