下面是小弟从网上找的一段SHELL代码,用来解决WEBLOGIC日志不能自动分割的问题,可是SHELL脚本有误,运行的时候报
start.sh【7】:test:0403-004 Specify a paramater with this command 请各位大虾帮帮忙
You can use the following script to rotate, by size, the nohup.out file. The script takes a size parameter to check against the size of the nohup.out file. If the file is greater than that specified size, it will copy the file to a logs directory appending the date and time to it and will empty the existing nohup.out and continue the logging.
The script should be started as a daemon process so it is continually running in the background. It should be run from where you store nohup.out - usually the domain directory, and make sure that there is a logs directory underneath the directory where you have nohup.out.
The script will run continuously until killed by user.
-----------
#!/bin/bash
counter=1
file=nohup.out
while [ "$counter" != "0" ]
do
size=`ls -la nohup.out | awk '{print $5}'`
if [ $size -gt $1 ]
then
date=`date +%m%d%y-%H%M%S`
cp "$file" log/"$file.$date"
cat /dev/null > "$file"
fi
done
-----------
Thanks and please let me know if it works at your end.
|
很明显是需要一个参数么,在运行这个脚本时你要指定"$1",是个整数,就是if [ $size -gt $1 ]里面的,他就是用来分割文件大小的界限。
|
那你应该看下,那个看那个存放拷贝后的目录是不是存在,就是log/这个目录,或者你可以重新指定一个目录,比如指定到cp "$file" /var/log/[/color]"$file.$date",运行完之后查看/var/log/是不是生成了那个拷贝后的文件。