Fli
04-18-2015, 10:52 AM
Hello, i just want to share this bash script code.
# definning emptybuffer function which will sleep 3600 seconds and empty buffer file when called.
# these commands (sleep, >) will be executed on background and script can continue to run
emptybuffer(){
sleep 3600
>/root/script/buffer
}
# if there is no "sleep 3600" process running, then we execute it (function emptybuffer)
if [ "$(ps x | grep "sleep 3600" | wc -l)" -lt "2" ];then
emptybuffer &
fi
Please if you know any other ways to simply execute linux command from bash script on background, please kindly share, thx
# definning emptybuffer function which will sleep 3600 seconds and empty buffer file when called.
# these commands (sleep, >) will be executed on background and script can continue to run
emptybuffer(){
sleep 3600
>/root/script/buffer
}
# if there is no "sleep 3600" process running, then we execute it (function emptybuffer)
if [ "$(ps x | grep "sleep 3600" | wc -l)" -lt "2" ];then
emptybuffer &
fi
Please if you know any other ways to simply execute linux command from bash script on background, please kindly share, thx