linux shell 0403-011,shell脚本出现 test:0403-004 Specify a paramater with this command
下面是小弟從網(wǎng)上找的一段SHELL代碼,用來解決WEBLOGIC日志不能自動分割的問題,可是SHELL腳本有誤,運(yùn)行的時候報
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.
|
很明顯是需要一個參數(shù)么,在運(yùn)行這個腳本時你要指定"$1",是個整數(shù),就是if?[?$size?-gt?$1?]里面的,他就是用來分割文件大小的界限。
|
那你應(yīng)該看下,那個看那個存放拷貝后的目錄是不是存在,就是log/這個目錄,或者你可以重新指定一個目錄,比如指定到cp?"$file"?/var/log/[/color]"$file.$date",運(yùn)行完之后查看/var/log/是不是生成了那個拷貝后的文件。
總結(jié)
以上是生活随笔為你收集整理的linux shell 0403-011,shell脚本出现 test:0403-004 Specify a paramater with this command的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php5.4环境升级,CentOS环境中
- 下一篇: linux 其他常用命令