21 lines
527 B
Bash
21 lines
527 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
JOBS_DIR=~/day_2/jobs
|
||
|
LOGS_DIR=~/day_2/logs
|
||
|
|
||
|
# Make sure that needed directories exist
|
||
|
mkdir -p "$JOBS_DIR"
|
||
|
mkdir -p "$LOGS_DIR"
|
||
|
|
||
|
# Listen to CLOSE_WRITE event to run script after copying is done
|
||
|
inotifywait -m -e close_write --format "%f" run | while read FILE
|
||
|
do
|
||
|
echo "Running job $FILE"
|
||
|
|
||
|
# Adding execution permission
|
||
|
chmod u+x "$JOBS_DIR"/"$FILE"
|
||
|
|
||
|
# Running job script with output and error redirection
|
||
|
"$JOBS_DIR"/"$FILE" 1> "$LOGS_DIR"/"$FILE".out 2> "$LOGS_DIR"/"$FILE".err
|
||
|
done
|