Created
July 30, 2020 07:49
-
-
Save ag-michael/254e769320eacb50a8fe9174d365000b to your computer and use it in GitHub Desktop.
Cron job script to run run-taxii-poll.py
This file contains 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
#!/bin/bash | |
# Run 'run-taxii-poll.py' to poll taxii feeds. | |
# Set start and end time for the time range of the poll | |
export START=$(date --date='8 hours ago' "+%Y-%m-%dT%H:%M:%S") | |
export END=$(date "+%Y-%m-%dT%H:%M:%S") | |
# Timestamp for the log file | |
export TS=$(date '+%Y.%m.%d_%H.%M.%S') | |
# After this many seconds, the job will be killed | |
export TIMEOUT=10800 | |
# Path of the configuration files | |
export CONFIG="<path>/config/alienvault/" | |
# Log file suffix | |
export FEED="alienvault" | |
# ---- DO NOT edit below this line ---- | |
ps aux | grep "$CONFIG" | grep -v 'grep' | |
already_running=$? | |
if [ $already_running -eq 1 ] # Not running | |
then | |
cd <some path>/MISP-Taxii-Server/scripts && | |
timeout -s SIGKILL $TIMEOUT /usr/bin/python3 <some path>/MISP-Taxii-Server/scripts/run-taxii-poll.py \ | |
-c "$CONFIG" -v --start "$START" --end "$END" -s 2>&1 > "<some path>/log/run-poll-$FEED_$TS.log" | |
else | |
echo "Already running,not running a new script." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment