I have this script that I found online to read from a fifo and import it into mysql:
#
# Created by Tadghe Patrick Danu
#
#!/bin/bash
if [ -e /tmp/mysql.pipe ]; then
while [ -e /tmp/mysql.pipe ]
do
mysql -u syslog --password=mypassword syslogdb < /tmp/mysql.pipe
done
else
mkfifo /tmp/mysql.pipe
fi
I have scheduled this script to run as a cron job and it works, however, every time it runs, it spawns a new instance, so when I look at the processes I see a bunch of processed running the script. How can I make it run only if it is not running already? I would like to have only one instance of this running at a time.
Thanks,