I have the following piece of code creating an rsync process launched in
the early hours of every morning to sync a NAS from another upstream. I
have only included the business part of the file, the beginning of it is
to do with setting up the variable values used in these lines. As you
will note, there are two debugging statements trapping the output of ps ...
# Debug Line 1:
ps | grep -v grep | grep tutsync.sh > $HD/rsync.log
echo "Syncing the following shares with rsync: ${SHARES}" >> $HD/rsync.log
for SHARE in ${SHARES}
do
# Debug Line 2:
ps | grep -v grep | grep tutsync.sh >> $HD/rsync.log
echo "nice -n ${NICE} rsync ${OPTIONS}
${SOURCE}/${SHARE}/ ${BU}/${SHARE}/"
nice -n ${NICE} rsync ${OPTIONS} ${SOURCE}/${SHARE}/
${BU}/${SHARE}/
done | grep -v '/$' >> $HD/rsync.log 2>&1
... because, when run, the process appears to duplicate itself within
the for loop - not only does the tutsync.sh process itself get
duplicated, but also the rsync process it launches as well, as can be
proven by launching with a trailing & and running a similar command from
the shell:
~ # cat $HD/rsync.log
32453 root 2720 S /bin/sh /opt/share/bin/tutsync.sh
Syncing the following shares with rsync: A List Of Shares
32453 root 2720 S /bin/sh /opt/share/bin/tutsync.sh
32458 root 2720 S /bin/sh /opt/share/bin/tutsync.sh
receiving incremental file list
etc
~ # pf rsync
9680 root 1972 S /opt/bin/rsync --ipv4 --daemon
--config=/etc/rsyncd.conf
32467 root 2908 R N rsync -Drltugpv --exclude=*.flv
--exclude=*.partial.* --exclude=*.part --exclude=**/.streams
32468 root 49772 S N rsync -Drltugpv --exclude=*.flv
--exclude=*.partial.* --exclude=*.part --exclude=**/.streams
What is going on, why are the processes duplicating themselves?
--
Fake news kills!
I may be contacted via the contact address given on my website:
www.macfh.co.uk