I am trying to get the follow script to run in the background on the 'fly'. I can launch it via cron and it will run in the background. BUT when I launch it from the command line it will run in the foreground. I figure it has to do with the while loop I have, but I have no clue how I can run the perl script (i didnt write the perl nor have any perl skills at this point) every 5 secs without a loop.
#! /bin/ksh
#
case "$1" in
start)
touch /tmp/vmstat.lk
while [ -f /tmp/vmstat.lk ]
do
su - weblogic -c "/usr/local/scripts/vmstat.pl"
sleep 5
done
;;
stop)
rm /tmp/vmstat.lk
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
I've tried that. I am assuming that because I have it set using a start and stop ex:start_vmstat start or start_vmstat stop, that when I add the % it is either ignoring it or it is having no effect.
If you want to background what I think you want to background, put your while loop inside parentheses and put an ampersand after the closing parenthesis.
using your suggestion I put the () around the while...done adding the % at the end, ended up getting a syntax error % unexpected. I am going to try several variations of what was suggested.