版权声明:欢迎转载!如果不喜欢请留言说明原因再踩!谢谢,我也可以知道原因,不断进步!! https://blog.csdn.net/Scythe666/article/details/82968762
Watch is designed to run in a console window. Printing its output to file is inconvenient, because of the extensive amount of unprintable formatting characters.
You can try this without watch, if the exact 60 seconds is not an issue:
while <some condition>
do
<mycommand> 2>&1 | tee -a /path/to/logfile
sleep 60
done
This saves the output to a log file and shows it on console as well.
我实践ok
#!/bin/bash
print_accuracy() {
echo multi_gpus
cat multi_gpus/slurm* | grep '* Prec@1'
echo -e "\n"
echo multi_gpus2
cat multi_gpus2/slurm* | grep '* Prec@1'
echo -e "\n"
echo multi_gpus3
cat multi_gpus3/slurm* | grep '* Prec@1'
echo -e "\n"
echo multi_gpus4
cat multi_gpus4/slurm* | grep '* Prec@1'
echo -e "\n"
echo multi_gpus5
cat multi_gpus5/slurm* | grep '* Prec@1'
echo -e "\n"
echo multi_gpus6
cat multi_gpus6/slurm* | grep '* Prec@1'
echo -e "\n"
}
while true
do
print_accuracy 2>&1 | tee log.log
sleep 5
done