I'm monitoring a folder which is receiving log files. For each log file received, I need to send it to a remote server via SCP. SCP transfer is done via transfer.sh script. Since I need to perform a transfer for each file, its probable that a single file may delay other new files. I would like to "create" a new parallel process for each file in my directory.
MONITOR_FOLDER='/repository/'
PATTERN='log_*'
for log_file in $MONITOR_FOLDER$PATTERN
do
echo "$(date +%c) monitor() Processing $log_file CDR file..."
parallel --will-cite -n0 "sh transfer.sh $log_file 1" ::: {1..1}
done
the $MONITOR_FOLDER$PATTERN can return 0 or more files. When there is more than 1 file, I want to create a parallel process per file. The following command display the correct list.
ls $MONITOR_FOLDER | grep 'log_*'
Question:
1) For each entry use it as param for my shell script and at the same time create a new process without the loop
&to it?