我正在尝试编写一个脚本来备份由应用程序管理的数据库,并且想知道是否有一种更简单的方法来实现它。我想我把事情弄复杂了。
基本上,我将停止应用程序服务(除了数据库之外),并将其保存到文本文件中,文本文件被读取,直到它给出适当的输出。然后,我运行一个脚本,将数据库导出到两个文件,并将输出写入另一个文本文件,该文本文件被读取,直到成功。然后,我再次启动服务。
以下是代码:
#!/bin/bash
#Make sure to run in the right folder!
echo "Here it will stop the manager services"
/etc/init.d/arcsight_services stop manager > /tmp/tmp/mangerstatusdown.txt
while [["./rr.sh /tmp/tmp/managerstatusdown.txt" != "[manager status down]"]]
do
echo "Not Ready Yet"
read -p "Do you think it's ready to move on?"
done
echo "Now it will export the database"
/opt/arcsight/manager/bin/arcsight export_system_tables > /tmp/tmp/systemtables.txt
while [["./rr.sh /tmp/tmp/systemtables.txt" != "[system tables export successful]" ]]
do
echo "Not Ready Yet"
read -p "Do you think it's ready to move on?"
done
echo "Here it will start the manager again"
/etc/init.d/arcsight_services start manager这是引用的rr.sh脚本:
while IFS=' ' read -r line || [[ -n "$line"]]; do
echo "Text read from file: $line"
done < "$1"
#run as follows:
#chmod +x rr.sh
#./rr.sh filename.txt这实际上是我的第一个剧本,所以当你解释的时候请记住这一点!
发布于 2017-10-17 13:23:01
bash不直接进行字符串比较;您需要使用特定的命令。
while [[ "$(./rr.sh /tmp/tmp/systemtables.txt)" != "[system tables export successful]" ]]
do https://stackoverflow.com/questions/46791094
复制相似问题